Skip to content

Commit

Permalink
Merge pull request #220 from spira/analysis-zOrKWq
Browse files Browse the repository at this point in the history
Applied fixes from StyleCI
  • Loading branch information
zakhenry committed Sep 4, 2015
2 parents c8d6fd3 + 7b44dd6 commit 9b55017
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions api/app/Services/ModelFactoryInstance.php
Expand Up @@ -169,7 +169,6 @@ public function setCollection(Collection $collection)
*/
private function built()
{

$entities = $this->getPredefinedOrMocks();

$this->setEntityType();
Expand Down Expand Up @@ -221,7 +220,7 @@ private function modifyEntity(BaseModel $entity)
$entity->setHidden($newHidden);
}

if($this->customizations){
if ($this->customizations) {
foreach ($this->customizations as $key => $value) {
$entity->{$key} = $value;
}
Expand Down Expand Up @@ -265,7 +264,6 @@ public function modified()
*/
public function transformed()
{

$entity = $this->modified();

if (!$this->transformer) {
Expand Down Expand Up @@ -356,7 +354,7 @@ public function create(array $attributes = [])
*/
private function getModelMock($count = 1)
{
if (is_null($this->factoryInstance)){
if (is_null($this->factoryInstance)) {
throw new \LogicException("No factory class passed to model factory, cannot generate a mock");
}

Expand All @@ -373,39 +371,31 @@ private function getModelMock($count = 1)
private function getPredefinedOrMocks()
{
if ($this->entityCount > 1) {

$collection = new Collection();

if ($this->predefinedEntities) {

if ($this->predefinedEntities instanceof Collection) {
$collection = $collection->merge($this->predefinedEntities->random($this->entityCount));
}else{
} else {
$collection->push($this->predefinedEntities);
}

}

if ($collection->count() < $this->entityCount) {
$collection = $collection->merge($this->getModelMock($this->entityCount - $collection->count()));
}

return $collection;

} else {

if ($this->predefinedEntities){

if ($this->predefinedEntities) {
if ($this->predefinedEntities instanceof Collection) {
return $this->predefinedEntities->random();
}else{
} else {
return $this->predefinedEntities;
}

}

return $this->getModelMock();

}
}
}

0 comments on commit 9b55017

Please sign in to comment.