getting first element of prepared data

@param bool $object
@return object|array|null
@throws ConditionNotAllowedException
969044
public function first($object = false)
    {
        $this->prepare();

        $data = $this->_map;
        if (count($data) > 0) {
            return $this->prepareResult(reset($data), $object);
        }

        return null;
    }
1239969
protected static function convert_object_to_array($object) {
	if (is_object($object) == false) {
		throw new \Exception('can only convert objects');
	}
	
	if ($object instanceof \alsvanzelf\jsonapi\resource) {
		return $object->get_array();
	}
	
	return get_object_vars($object);
}
927438
public static function get($object): Proxy
    {
        if (self::$proxies === null) {
            self::$proxies = new \SplObjectStorage();
        }

        if (!isset(self::$proxies[$object])) {
            self::$proxies[$object] = new Proxy($object);
        }

        return self::$proxies[$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;
    }
547091
public function extract($object)
    {
        $this->prepare($object);

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

        return $this->extractByReference($object);
    }
1010504
public function obscureSensitiveData($object)
    {
        if (is_array($object)) {
            return $this->_obscureSensitiveArray($object);
        }

        if ($object instanceof ArrayAccess) {
            return $this->_obscureSensitiveObject($object);
        }

        if (is_string($object) || is_numeric($object)) {
            return $this->_obscureSensitiveElements($object);
        }

        return $object;
    }
1251923
public function first($type = 'object')
    {
        $data = self::query($type);
        if (Collection::count($data) > 0) {
            return $data[0];
        }
    }
735082
public function fetchFirstObj(string $class = null)
    {
        if (!$this->wasExecuted()) {
            $this->exec();
        }

        $data = $this->fetchFirst();

        if ($data === null) {
            return null;
        }

        if ($class == null) {
            $obj = new \stdClass();

            foreach ($data as $field => $value) {
                $obj->$field = $value;
            }

            return $obj;
        } else {
            return new $class($data);
        }
    }
962059
private function getObjectState($object)
    {
        $class = new \ReflectionClass($object);
        $visibility = \ReflectionProperty::IS_PRIVATE | \ReflectionProperty::IS_PROTECTED;
        $values = [];

        do {
            foreach ($class->getProperties($visibility) as $property) {
                $property->setAccessible(true);
                $values[$property->getName()] = $property->getValue($object);
            }

            $class = $class->getParentClass();
            $visibility = \ReflectionProperty::IS_PRIVATE;
        } while ($class);

        return get_object_vars($object) + $values;
    }
322547
public function getValue($object = null)
    {
        $name = $this->getName();

        if ($object instanceof Proxy && ! $object->__isInitialized()) {
            $originalInitializer = $object->__getInitializer();
            $object->__setInitializer(null);
            $val = $object->$name ?? null;
            $object->__setInitializer($originalInitializer);

            return $val;
        }

        return isset($object->$name) ? parent::getValue($object) : null;
    }
563078
public static function objectArray($object)
    {
        if (is_object($object)) {
            $reflectionClass = new \ReflectionClass(get_class($object));
            $array = [];
            foreach ($reflectionClass->getProperties() as $property) {
                $property->setAccessible(true);
                $array[$property->getName()] = $property->getValue($object);
                $property->setAccessible(false);
            }

            //If above method failed? try, this one.
            $array = (empty($array)) ? json_decode(json_encode($object), true) : $array;

            return $array;
        }

        return false;
    }
1161951
public function nth($index, $object = false)
    {
        $this->prepare();

        $data = $this->_map;
        $total_elm = count($data);
        $idx =  abs($index);

        if (!is_integer($index) || $total_elm < $idx || $index == 0 || !is_array($this->_map)) {
            return null;
        }

        if ($index > 0) {
            $result = $data[$index - 1];
        } else {
            $result = $data[$this->count() + $index];
        }

        return $this->prepareResult($result, $object);
    }
274252
public static function getFromObject($object, string $key)
    {
        if ($object == null) {
            return null;
        }
        if (!isset ($object->{$key})) {
            return null;
        }
        return $object->{$key};
    }
962055
public function getLabeledPropertiesToBeSet($object)
    {
        return array_filter($this->getLabeledProperties(), function (LabeledPropertyMetadata $labeledPropertyMetadata) use ($object) {
            return true === $labeledPropertyMetadata->getValue($object);
        });
    }
1025937
public function getFirst()
    {
        $first = null;

        if (count($this->objects) > 0) {
            $first = reset($this->objects);
        }

        return $first;
    }
618739
public function populateDefaultRelations(DataObject $object)
    {
        foreach ($object->hasOne() as $name => $class) {
            
            if ($id = $this->getDefaultRelation($class)) {
                $object->{$name . 'ID'} = $id;
            }
            
        }
        
        return $object;
    }
703096
public function delete($object, $meta=null)
    {
        $query = new Query\Criteria();

        if (!is_object($object)) {
            throw new \BadMethodCallException("Please use deleteTable()");
        } 

        if ($meta) {
            $meta = !$meta instanceof Meta ? $this->mapper->getMeta($meta) : $meta;
        } else {
            $meta = $this->mapper->getMeta(get_class($object));
        }

        if (!$meta->canDelete) {
            throw new Exception("Meta {$meta->id} prohibits delete");
        }

        event_before: {
            if (isset($meta->on['beforeDelete'])) {
                foreach ($meta->on['beforeDelete'] as $cb) { $cb = [$object, $cb]; $cb(); }
            }
            if (isset($this->on['beforeDelete'])) {
                foreach ($this->on['beforeDelete'] as $cb) { $cb($object, $meta); }
            }
        }

        $query->where = $meta->getIndexValue($object);
        $return = $this->executeDelete($meta, $query);

        event_after: {
            if (isset($meta->on['afterDelete'])) {
                foreach ($meta->on['afterDelete'] as $cb) { $cb = [$object, $cb]; $cb(); }
            }
            if (isset($this->on['afterDelete'])) {
                foreach ($this->on['afterDelete'] as $cb) { $cb($object, $meta); }
            }
        }

        return $return;
    }