コード例 #1
0
 /**
  * Get either the predefined (subset of) collection/model, or.
  * @return Collection|mixed|BaseModel
  */
 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 {
                 $collection->push($this->predefinedEntities);
             }
         }
         if ($collection->count() < $this->entityCount) {
             /** @var Collection $collection */
             $collection = $collection->merge($this->getModelMock($this->entityCount - $collection->count()));
         }
         return $collection;
     } else {
         if ($this->predefinedEntities) {
             if ($this->predefinedEntities instanceof Collection) {
                 return $this->predefinedEntities->random();
             } else {
                 return $this->predefinedEntities;
             }
         }
         return $this->getModelMock();
     }
 }