Convert an object into a list of [key, value] pairs.

@category Object Functions

@param traversable $object the list of items to convert to pairs

@return array
344664
public static function pairs($object)
    {
        $result = [];
        static::each($object, function ($item, $key) use (& $result) {
            $result[] = [$key, $item];
        });

        return $result;
    }
1110283
public function extract($object)
    {
        $data = parent::extract($object);

        foreach ($this->getFreeValuesKeys() as $key) {
            $data[$key] = $object->get($key);
        }

        return $data;
    }
10858
static function toList(iterable $iterable): array
    {
        return $iterable instanceof \Traversable ? iterator_to_array($iterable, false) : array_values($iterable);
    }
287497
public static function values($object)
    {
        if ($object instanceof \stdClass)
            $object = (array)$object;

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

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

        return $result;
    }
1277971
public static function toArray( $object )
    {
        if ( is_object( $object ) )
        {
            return get_object_vars( $object );
        }

        if ( is_array( $object ) )
        {
            return array_map(
                array(
                    __CLASS__,
                    'toArray'
                ),
                $object
            );
        }

        // Return array
        return $object;
    }
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;
    }
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 ?? [];
    }
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;
    }
932824
public function toArray($object, $deep = self::SHALLOW)
    {
        return $deep ? $this->toDeepArray($object) : $this->toShallowArray($object);
    }
286797
public function getPossibleTransitions($object)
    {
        $transitions = [];
        $sm = $this->factory->get($object, $this->activeGraph);

        foreach ($sm->getPossibleTransitions() as $name) {
            $transitions[$name] = array(
                'name' => $name,
                'graph' => $this->activeGraph,
                'color' => $this->getTransitionColor($name),
                'label' => $this->getTransitionLabel($name),
            );
        }

        return $transitions;
    }
953126
protected function _getObjectFieldValues($object)
    {
        $result = array();
        $fields = $object->getFieldNames();
        $tableName = $object->getCoreTableName();
        foreach ($fields as $field) {
            $fieldName = $tableName.'__'.$field;
            $result[$field] = $object->$fieldName->value;
        }

        return $result;
    }
1204218
protected function getIndexablePropertiesAndValuesFromObject($object)
    {
        $className = TypeHandling::getTypeForValue($object);
        $data = [];
        foreach ($this->indexInformer->getClassProperties($className) as $propertyName) {
            if (ObjectAccess::isPropertyGettable($object, $propertyName) === false) {
                continue;
            }

            $value = ObjectAccess::getProperty($object, $propertyName);
            if (($transformAnnotation = $this->reflectionService->getPropertyAnnotation($className, $propertyName, TransformAnnotation::class)) !== null) {
                $value = $this->transformerFactory->create($transformAnnotation->type)->transformByAnnotation($value, $transformAnnotation);
            }

            $data[$propertyName] = $value;
        }

        return $data;
    }
1185804
public function convert($object)
    {
        $className = \get_class($object);
        if (isset($this->convertersMap[$className])) {
            $converter = $this->convertersMap[$className];
        } else {
            $converter = $this->genericConverter;
        }

        return $converter->convert($object);
    }
1190405
protected function normalizeAsArray($object) : array
    {
        $wrapper = $this->factory->make($object);

        $value = $wrapper->getEntityAttributes();

        if ($this->asJson) {
            $value = json_encode($value);
        }

        return [$this->relation => $value];
    }
1064595
protected static function rawData( $object )
    {
        if ( is_object( $object ) )
        {
            $hash = spl_object_hash( $object );

            if ( isset( self::$rawCheck[$hash] ) )
            {
                return array( '#recursion#' => $hash );
            }

            self::$rawCheck[$hash] = true;
        }

        $object = (array) $object;

        foreach ( $object as $key => $value )
        {
            if ( is_array( $value ) || is_object( $value ) )
            {
                $object[$key] = self::rawData( $value );
            }
        }

        return (object) $object;
    }
971724
public function getTags($object)
    {
        $tags = $this->_collectTags($object);
        
        if (is_string($tags)) {
            $tags = array(
                $tags => $tags
            );
        } elseif (!is_array($tags)) {
            return array();
        }
        
        return $tags;
    }
705205
public static function objectToArray($object = false) {

        if ($object && Validate::isObject($object)) {

            return self::objectToArrayRecursive($object);
        }

        return false;
    }