Extract values from an object

@param  object $object
@return array
547091
public function extract($object)
    {
        $this->prepare($object);

        if ($this->byValue) {
            return $this->extractByValue($object);
        }

        return $this->extractByReference($object);
    }
322306
protected function _toArray($object)
    {
        $reflectionClass = new \ReflectionClass(get_class($object));
        $array           = array();
        foreach ($reflectionClass->getProperties() as $property)
        {
            $property->setAccessible(true);
            $array[$property->getName()] = $property->getValue($object);
            $property->setAccessible(false);
        }
        return $array;
    }
853113
public static function get_by_object($object) {
		$db = Database::Get();
		$class = get_class($object);
		$data = $db->get_all('SELECT * FROM object_text WHERE classname=? AND object_id=?', [ $class, $object->id ]);
		$object_texts = [];
		foreach ($data as $details) {
			$object_text = new self();
			$object_text->id = $details['id'];
			$object_text->details = $details;

			$object_texts[] = $object_text;
		}

		return $object_texts;
	}
158741
private function extractData(object $data): array
    {
        if ($data instanceof \stdClass) {
            return (array) $data;
        }

        $extracted = [];
        $reflection = new \ReflectionObject($data);
        foreach (
            $reflection->getMethods(ReflectionMethod::IS_PUBLIC) as $method
        ) {
            if (!$this->isGetMethod($method)) {
                continue;
            }

            $extracted[$this->getAttributeName($method)] = $method->invoke(
                $data
            );
        }

        return $extracted;
    }
1285087
public static function serialize($object) : array
    {
        $serializer = new static();
        $data = $serializer->serializeObject($object);

        if (sizeof($serializer->referencesUsed)) {
            foreach ($serializer->referencesUsed as $index) {
                $data['@references'][$index] = $serializer->references[$index];
            }
        }

        return $data;
    }
718647
private static function objectProperties($object): array
    {
        if ($object instanceof Serializable) {
            return ['$' => $object->serialize()];
        }

        $class = get_class($object);
        $properties = [];

        do {
            try {
                $properties += Closure::bind(function () use ($object) {
                    return get_object_vars($object);
                }, null, $class)->__invoke();
            } catch (Throwable $e) {
                return get_object_vars($object);
            }
        } while ($class = get_parent_class($class));

        return method_exists($object, '__sleep')
            ? array_intersect_key($properties, array_flip($object->__sleep()))
            : $properties;
    }
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;
    }
1218904
public static function getExtractPropertys($object)
    {
        $list = AnnotationManager::getPropertiesAnnotations(BeanFactory::getObjectClass($object), ExtractProperty::class);
        if(null !== $list)
        {
            return $list;
        }
        else
        {
            return [];
        }
    }
797681
public function extract($object)
    {
        if (! $object instanceof ConversionInterface) {
            throw new InvalidArgumentException(sprintf(
                'Invalid object "%s" provided; must be an instance of "%s".',
                is_object($object) ? get_class($object) : gettype($object),
                ConversionInterface::CLASS
            ));
        }

        return $object->toArray();
    }
61752
protected function getObjectValues(object $object): array
    {
        $class = new ReflectionClass(get_class($object));
        $constructor = $class->getConstructor();
        if ($constructor instanceof ReflectionMethod) {
            foreach ($constructor->getParameters() as $parameter) {
                $name = $parameter->getName();

                $property = $class->getProperty($name);
                $property->setAccessible(true);

                $value = $property->getValue($object);
                if (is_object($value) === true) {
                    $value = $this->getObjectValues($value);
                }

                $data[$name] = $value;
            }
        }

        return $data ?? [];
    }
415478
public function extract($object)
    {
        return [
            'newsId'        => $object->getNewsId(),
            'userId'        => $object->getUserId(),
            'title'         => $object->getTitle(),
            'slug'          => $object->getSlug(),
            'content'       => $object->getContent(),
            'description'   => $object->getDescription(),
            'pageHits'      => $object->getPageHits(),
            'image'         => $object->getImage(),
            'layout'        => $object->getLayout(),
            'lead'          => $object->getLead(),
            'dateCreated'   => $this->extractValue('dateCreated', $object->getDateCreated()),
            'dateModified'  => $this->extractValue('dateModified', $object->getDateModified()),
        ];
    }
470119
protected function extractByValue($object)
    {
        $fieldNames = array_merge($this->metadata->getFieldNames(), $this->metadata->getAssociationNames());
        $methods    = get_class_methods($object);
        $filter     = $object instanceof FilterProviderInterface
            ? $object->getFilter()
            : $this->filterComposite;

        $data = [];
        foreach ($fieldNames as $fieldName) {
            if ($filter && ! $filter->filter($fieldName)) {
                continue;
            }

            $getter = 'get' . Inflector::classify($fieldName);
            $isser  = 'is' . Inflector::classify($fieldName);

            $dataFieldName = $this->computeExtractFieldName($fieldName);
            if (in_array($getter, $methods)) {
                $data[$dataFieldName] = $this->extractValue($fieldName, $object->$getter(), $object);
            } elseif (in_array($isser, $methods)) {
                $data[$dataFieldName] = $this->extractValue($fieldName, $object->$isser(), $object);
            } elseif (substr($fieldName, 0, 2) === 'is'
                && ctype_upper(substr($fieldName, 2, 1))
                && in_array($fieldName, $methods)) {
                $data[$dataFieldName] = $this->extractValue($fieldName, $object->$fieldName(), $object);
            }

            // Unknown fields are ignored
        }

        return $data;
    }
934640
public function objectToArray($object)
    {
        if (!is_object($object) && !is_array($object)) {
            return $object;
        }
        if (is_object($object)) {
            $object = get_object_vars($object);
        }

        return array_map([get_class(), 'objectToArray'], $object);
    }
1319307
public function extract($object)
    {
        if (!$object instanceof PageInfo) {
            throw new \Exception('$object must be an instance of PageInfo');
        }
        /* @var $object PageInfo */
        $data = parent::extract($object);

        return $data;
    }
1037621
public static function keys($object)
    {
        if ($object instanceof \stdClass)
            $object = (array)$object;

        if (is_array($object))
            return array_keys($object);

        $result = [];
        static::each($object, function ($item, $key) use (& $result) {
            $result[] = $key;
        });

        return $result;
    }
1132899
public function extract($object)
    {
        if (!$object instanceof News) {
            throw new \Exception('$object must be an instance of News');
        }
        /* @var $object News */
        $data = parent::extract($object);

        return $data;
    }
63117
public function toArray($object)
    {
        $result = array();
        $className = $this->getFullClassName($object);
        $metadata = $this->metadataFactory->getMetadataForClass($className);
        foreach ($metadata->getProperties() as $property) {
            if (!$property->isExpose() || $this->propertySkipper->shouldSkip($property)) {
                continue;
            }

            $value = $this->exposeValue($object, $property);
            $value = $this->handleValue($value, $property, self::DIRECTION_SERIALIZE);

            if ($property->isNullSkipped() && $value === null) {
                continue;
            }

            $result[$property->getSerializedName()] = $value;
        }

        return $result;
    }