Prepare data for result

@param mixed $data
@param bool $isObject
@return array|mixed
763373
protected function prepareResult($data, $isObject)
    {
        $output = [];

        if (is_null($data) || is_scalar($data)) {
            return $data;
        }

        if ($this->isMultiArray($data)) {
            foreach ($data as $key => $val) {
                $val = $this->takeColumn($val);
                $output[$key] = $isObject ? (object) $val : $val;
            }
        } else {
            $output = json_decode(json_encode($this->takeColumn($data)), $isObject);
        }

        return $output;
    }
145653
public function loadObject($data)
    {
        if (!\is_object($data)) {
            throw new \InvalidArgumentException('param type error! must is object.');
        }

        return $this->bindData($this->data, $data);
    }
78232
function isObject(obj) {
  const objType = typeof obj;
  return objType === 'object' && Boolean(obj) && !Array.isArray(obj);
}
883002
public function makeData(Data $data): ?DataObjectFormat
    {
        if (!$data->isInstanceOf(Data::class)) {
            return null;
        }

        return DataObjectFormat::make($data);
    }
693692
private function prepareData()
    {
        $data = [];
        foreach (get_object_vars($this) as $property => $value) {
            if (in_array($property, ['apiHost', 'debug'])) {
                continue;
            }

            if ($property == 'format') {
                $data[$value] = '';
            } elseif (is_bool($value) && $value) {
                $data[$property] = '';
            } elseif (!is_null($value) && !is_bool($value)) {
                if (is_array($value)) {
                    foreach ($value as $key => $val) {
                        $value[$key] = $val;
                    }
                } else {
                    $value = $value;
                }

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

        if (empty($data) && $this->debug) {
            throw new \Exception('Query have not data');
        }

        $data = http_build_query($data);

        return $data;
    }
148639
public function initByData( array $data = null )
    {

        if( !$data ) {
            return null;
        }

        // table inheritance - ghetto?
        /*
        if( isset( $data['tableoid'] ) ) {
            if( $data['tableoid'] != static::OID ) {
                $repo = Repository::init( $data['tableoid'] );
                return $repo->initByData( $data );
            }
            unset( $data['tableoid'] );
        }
        */

        $key = call_user_func(
            array( $this->entityClass, 'keyGet' ),
            $data
        );

        // is this already in the cache? Are we initalising something we've already loaded?
        if( isset( $this->instancesPersisted[$key] ) ) {

            // Late loading? Don't need this anymore.
            $obj = $this->instancesPersisted[$key];
            $obj->__construct( $data );
            return $obj;

        }

        $obj = parent::initByData($data);
        $this->instancesPersisted[$key] = $obj;

        return $obj;

    }
650750
static public function toObject($data)
    {
        if (is_object($data)) {
            return $data;
        }
        if (is_array($data)) {
            $data = json_encode($data);
        }
        return json_decode($json);
    }
870221
public static function data($data, $type = null)
    {
        $type === null && $type = MongoBinData::BYTE_ARRAY;

        return new MongoBinData($data, $type);
    }
147286
public function prepare($query)
    {
        $this->connect();
        $isObject = $query instanceof Query;
        $statement = $this->_connection->prepare($isObject ? $query->sql() : $query);
        $result = new MysqlStatement($statement, $this);
        if ($isObject && $query->isBufferedResultsEnabled() === false) {
            $result->bufferResults(false);
        }

        return $result;
    }
420200
public static function create($data)
    {
        if ($data instanceof self) {
            return $data;
        }

        if (\is_array($data)) {
            return self::_createFromArray($data);
        }

        if (\is_string($data)) {
            $class = self::class === \get_called_class() ? Script::class : \get_called_class();

            return new $class($data);
        }

        throw new InvalidException('Failed to create script. Invalid data passed.');
    }
502701
public function populateObjects(DataObject $object, $data, $fixtures)
    {
        // Populate Objects:
        
        foreach ($data as $name => $value) {
            
            // Detect Object:
            
            if ($this->isObject($object, $name)) {
                
                // Trim Name:
                
                $name = ltrim($name, '->');
                
                // Populate Object:
                
                if ($subObject = $object->$name) {
                    
                    foreach ($value as $k => $v) {
                        $subObject->$k = $v;
                    }
                    
                    $subObject->write();
                    
                }
                
            }
            
        }
    }
806880
private function prepareResultPage($data)
    {
        /* convert service data object into stdClass/array */
        $type = $this->getOutDataType();
        $stdObj = $this->outputProcessor->convertValue($data, $type);
        /* prepare result page with JSON data */
        $result = $this->resultFactory->create(AResultFactory::TYPE_JSON);
        $result->setData($stdObj);
        return $result;
    }
782928
public function process(DataObjectInterface $data = null)
    {
        if ( ! is_null($data)) {
            $this->data = $data;
        }

        $this->before();

        $this->doProcessing();

        $this->after();

        return $this->getResult();
    }
1163091
public function fillObjectWithRawData($targetObject, stdClass $rawData)
	{
		$this->filler->fillObjectWithRawData($targetObject, $rawData);

		return $targetObject;
	}
564230
private function convertObjectToArray($data)
    {
        $converted = [];
        foreach($data as $key => $value) {
            if(is_object($value)) {
                $converted[$key] = $this->convertObjectToArray($value);
            } else {
                $converted[$key] = $value;
            }
        }

        return $converted;
    }
609239
public function getData($raw = false)
    {
        if (true === $raw) {
            return $this->data;
        }

        $this->prepare();

        return $this->dataPrepared;
    }
111489
private function convertArrayObjects($data)
    {
        if ($data instanceof \ArrayObject || $data instanceof \stdClass) {
            $data = (array) $data;
        }
        if (\is_array($data)) {
            foreach ($data as $k => $v) {
                $data[$k] = $this->convertArrayObjects($v);
            }
        }

        return $data;
    }