Extract values from an object

@param  UserInterface $object
@return array
190642
public function extract($object)
    {
        $data = [
            'login' => $object->getLogin(),
            'name' => $object->getName(),
            'email' => $object->getEmail(),
            'role' => $object->getRole(),
        ];
        if ($object->getId() !== null) {
            $data['id'] = $object->getId();
        }
        return $data;
    }
907875
public function getUsers($permission, $object)
	{
		$permObject = $this->permission->findByPermissionAndObject($permission, $object);
		
		if(!$permObject)
			return array();
		
		return $this->userObjectPermission->findByObject($permObject, $object);
	}
773887
public function getData($object)
    {
        return [
            'OXID'          => $object->getId(),
            'OXRATING'      => $object->getRating(),
            'OXTEXT'        => $object->getText(),
            'OXOBJECTID'    => $object->getObjectId(),
            'OXUSERID'      => $object->getUserId(),
            'OXTYPE'        => $object->getType(),
            'OXTIMESTAMP'   => $object->getCreatedAt(),
        ];
    }
1107428
protected function extractObjectProperties($object): array
    {
        $properties = [];

        $reflection = new \ReflectionObject($object);

        // obtain public, protected and private properties of the class itself:

        foreach ($reflection->getProperties() as $property) {
            if ($property->isStatic()) {
                continue; // omit static properties
            }

            $property->setAccessible(true);

            $properties["\${$property->name}"] = $property->getValue($object);
        }

        // obtain any inherited private properties from parent classes:

        while ($reflection = $reflection->getParentClass()) {
            foreach ($reflection->getProperties(\ReflectionProperty::IS_PRIVATE) as $property) {
                $property->setAccessible(true);

                $properties["{$reflection->name}::\${$property->name}"] = $property->getValue($object);
            }
        }

        return $properties;
    }
341926
public function getPropertyValuesArray($object)
    {
        $values = [];
        foreach ($this->entityPropertiesMetadata as $entityPropertyMetadata) {
            $v = $entityPropertyMetadata->getValue($object);
            if (is_object($v)) {
                switch (get_class($v)) {
                    case \DateTime::class:
                        $v = $v->getTimestamp();
                        break;
                }
            }
            $values[$entityPropertyMetadata->getPropertyName()] = $v;
        }

        return $values;
    }
543214
private function getItems(PropertyInterface $property)
    {
        $value = $this->getValue($property);
        if (!is_array($value['items']) || 0 === count($value['items'])) {
            return [];
        }

        return $value['items'];
    }
864829
private function convert(Array $object): Array {
    $parse = Array();
    foreach ($object as $key => $value) {
      if ($value instanceof stdClass) {
        $parse[$key] = $this->convert((Array) $value);
      } else {
        $parse[$key] = $value;
      }
    }
    return $parse;
  }
566207
public function get($object) : array
    {
        $values = $this->storage->get($object);

        return ($values === null) ? [] : $values;
    }
345911
public function extract($object)
    {
        $array = array();
        $methods = get_class_methods(get_class($object));

        foreach ($methods as $method) {
            preg_match('/^(get)(.*?)$/i', $method, $matches);
            if (!isset($matches[2])) {
                continue;
            }
            $key = StringUtil::snake($matches[2]);
            $array[$key] = $object->$method();
        }

        return $array;
    }
243893
public function extract($object)
    {
        $data = [];
        if ($object->getId() !== null) {
            $data['id'] = $object->getId();
        }
        $data['name'] = $object->getName();
        $data['isdefault'] = $object->isDefault() ? 1 : 0;
        return $data;
    }
607009
protected function getPersistentValues(PersistentObject $object) {
    $values = [];

    // attribute definitions
    $attributeDescs = $this->getAttributes();
    foreach($attributeDescs as $curAttributeDesc) {
      if ($curAttributeDesc instanceof RDBAttributeDescription) {
        // add only attributes that are defined in the object
        $attribName = $curAttributeDesc->getName();
        //if ($object->hasValue($attribName)) {
          $values[$attribName] = $object->getValue($attribName);
        //}
      }
    }
    return $values;
  }
204474
public function extract($object)
    {
        if (!$object instanceof TicketSubject) {
            throw new \InvalidArgumentException('$object must be an instance of TicketSubject');
        }
        /* @var $object TicketSubject */
        $data = parent::extract($object);

        return $data;
    }
207618
public function extract($object)
    {
        $data = ['name' => $object->getNormalizedName()];
        if ($object->hasParent()) {
            $data['source'] = strval($object->getParent()->getNormalizedName());
        }
        return $data;
    }
1103067
public function toArray($object)
    {
        $this->assertObjectInstance($object);

        return array_map(
            function (Field $field) use ($object) {
                return $field->get($object);
            },
            $this->getFields()
        );
    }
39597
public function extractFQCN(string $class, ResourceInterface $object): array
    {
        $json = $this->getHydrator($class)->extract($object);
        $json = $this->extractNestedResources($json, $object);
        $json = $this->extractCollectionResources($json, $object);
        $json = $this->extractRenameResourceProperties($json, $object);
        return $json;
    }
1270680
private function objectifyRoles(UserInterface $user)
    {
        $roles = [];

        foreach ($user->getRoles() as $role) {
            if (is_string($role)) {
                $role = new Role($role);
            } elseif (!$role instanceof RoleInterface) {
                throw new \InvalidArgumentException(sprintf('User roles must be an array of strings, or RoleInterface instances, but got %s.', gettype($role)));
            }

            $roles[] = $role;
        }

        return $roles;
    }
243293
private function extractProperties(
        object $object,
        MapInterface $properties
    ): MapInterface {
        $refl = $this->reflection($object);

        return $properties->reduce(
            new Map('string', 'mixed'),
            static function(MapInterface $carry, string $name, Property $property) use ($refl): MapInterface {
                return $carry->put(
                    $name,
                    $property
                        ->type()
                        ->forDatabase(
                            $refl->extract($name)->get($name)
                        )
                );
            }
        );
    }