Fakerino\Core\Entity\EntityInfo::getProperties PHP Method

getProperties() public method

Gets the properties of the object provided.
public getProperties ( integer $filter = ReflectionProperty::IS_PUBLIC ) : array
$filter integer
return array
    public function getProperties($filter = \ReflectionProperty::IS_PUBLIC)
    {
        $properties = array();
        $reflectionProperties = $this->reflectionEntity->getProperties($filter);
        foreach ($reflectionProperties as $property) {
            $properties[] = new Property($property->name, $property->isStatic());
        }
        return $properties;
    }

Usage Example

Beispiel #1
0
 /**
  * Fills properties.
  */
 public function fillProperties()
 {
     $entity = $this->entity;
     $entityInfo = new EntityInfo($entity);
     $entityProperties = $entityInfo->getProperties();
     foreach ($entityProperties as $property) {
         $propertyName = $property->getName();
         $fakeData = $this->faker->fake($propertyName)->toArray();
         if ($property->isStatic()) {
             $entity::${$propertyName} = $fakeData[0];
         } else {
             $entity->{$propertyName} = $fakeData[0];
         }
     }
 }