Skip to content

Commit

Permalink
Merge pull request #271 from analogueorm/analysis-z917PP
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
RemiCollin authored Jun 19, 2018
2 parents 51546ce + 9c8db81 commit e953af5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
10 changes: 5 additions & 5 deletions src/Relationships/MorphTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function match(array $results, $relation)
foreach (array_keys($this->dictionary) as $type) {
$results = $this->matchToMorphParents($type, $this->getResultsByType($type), $results);
}

return $results;
}

Expand All @@ -103,7 +103,7 @@ public function match(array $results, $relation)
*
* @param string $type
* @param EntityCollection $results
* @param array $parents
* @param array $parents
*
* @return array
*/
Expand All @@ -112,15 +112,15 @@ protected function matchToMorphParents($type, EntityCollection $results, array $
$mapper = $this->relatedMapper->getManager()->mapper($type);
$keyName = $mapper->getEntityMap()->getKeyName();

$keys = array_map(function($parent) use($keyName) {
$keys = array_map(function ($parent) use ($keyName) {
return $parent[$keyName];
}, $parents);

$parents = array_combine($keys, $parents);

foreach ($results as $result) {
$key = $result[$keyName];

if (isset($this->dictionary[$type][$key])) {
foreach ($this->dictionary[$type][$key] as $parent) {
$parents[$parent[$keyName]][$this->relation] = $result;
Expand Down
4 changes: 2 additions & 2 deletions src/System/Builders/ResultBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ protected function buildEmbeddedRelationships(array $results) : array
protected function queryEagerLoadedRelationships(array $results, array $eagerLoads) : array
{
$this->eagerLoads = $this->parseRelations($eagerLoads);

return $this->eagerLoadRelations($results);
}

Expand Down Expand Up @@ -196,7 +196,7 @@ public function eagerLoadRelations(array $results): array
foreach ($this->eagerLoads as $name => $constraints) {
// First, we'll check if the entity map has a relation and just pass if it
// is not the case

if (!in_array($name, $this->entityMap->getRelationships())) {
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions src/System/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ public function with($relations)
if (is_string($relations)) {
$relations = func_get_args();
}

$this->eagerLoad = array_merge($this->eagerLoad, $relations);

return $this;
Expand Down Expand Up @@ -572,7 +572,7 @@ public function getEntities($columns = ['*'])

// Run the query
$results = $this->query->get($columns);

// Pass result set to the mapper and return the EntityCollection
return $this->mapper->map($results, $this->getEagerLoads());
}
Expand Down
3 changes: 0 additions & 3 deletions tests/cases/EntityMapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

use Illuminate\Contracts\Cache\Repository;
use TestApp\User;
use TestApp\Foo;
use TestApp\Bar;

class EntityMapTest extends AnalogueTestCase
{
Expand All @@ -29,5 +27,4 @@ public function an_entity_map_is_cached_after_instantiation()
$cache = $this->app->make(Repository::class);
$this->assertTrue($cache->has(User::class));
}

}
5 changes: 3 additions & 2 deletions tests/cases/ProxyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public function many_relationships_within_the_with_property_are_always_eager_loa
});
$this->analogue->register(Foo::class, new class() extends EntityMap {
protected $with = ['bars'];

public function bars(Foo $foo)
{
return $this->hasMany($foo, Bar::class, 'food_id', 'id');
Expand Down Expand Up @@ -148,10 +149,10 @@ public function single_relationships_within_the_with_property_are_always_eager_l
$table->string('title');
});
$this->analogue->register(Foo::class, new class() extends EntityMap {

});
$this->analogue->register(Bar::class, new class() extends EntityMap {
protected $with = ['foo'];

public function foo(Bar $bar)
{
return $this->belongsTo($bar, Foo::class);
Expand All @@ -160,7 +161,7 @@ public function foo(Bar $bar)
$bar = new Bar();
$bar->title = 'Test';
$bar->foo = new Foo();
$bar->foo->title = "test";
$bar->foo->title = 'test';
mapper($bar)->store($bar);
$this->clearCache();
$loadedBar = mapper($bar)->find($bar->id);
Expand Down

0 comments on commit e953af5

Please sign in to comment.