Parses the data for this element

@param mixed $object The data

@throws ValidationException
169102
protected function parse($object)
    {
        if (! is_object($object)) {
            throw new ValidationException('Document has to be an object, "' . gettype($object) . '" given.');
        }

        if (! property_exists($object, 'data') and ! property_exists($object, 'meta') and ! property_exists($object, 'errors')) {
            throw new ValidationException('Document MUST contain at least one of the following properties: data, errors, meta');
        }

        if (property_exists($object, 'data') and property_exists($object, 'errors')) {
            throw new ValidationException('The properties `data` and `errors` MUST NOT coexist in Document.');
        }

        if (property_exists($object, 'data')) {
            $this->set('data', $this->parseData($object->data));
        }

        if (property_exists($object, 'meta')) {
            $this->set('meta', $this->create('Meta', $object->meta));
        }

        if (property_exists($object, 'errors')) {
            $this->set('errors', $this->create('ErrorCollection', $object->errors));
        }

        if (property_exists($object, 'included')) {
            if (! property_exists($object, 'data')) {
                throw new ValidationException('If Document does not contain a `data` property, the `included` property MUST NOT be present either.');
            }

            $this->set('included', $this->create('ResourceCollection', $object->included));
        }

        if (property_exists($object, 'jsonapi')) {
            $this->set('jsonapi', $this->create('Jsonapi', $object->jsonapi));
        }

        if (property_exists($object, 'links')) {
            $this->set('links', $this->create('DocumentLink', $object->links));
        }
    }
136328
protected function parse($object)
    {
        if (! is_object($object)) {
            throw new ValidationException('Resource has to be an object, "' . gettype($object) . '" given.');
        }

        if (! property_exists($object, 'type')) {
            throw new ValidationException('A resource object MUST contain a type');
        }

        if (is_object($object->type) or is_array($object->type)) {
            throw new ValidationException('Resource type cannot be an array or object');
        }

        $this->set('type', strval($object->type));

        if (
            $this->getManager()->getParam('optional_item_id', false) === false
            or ! $this->getParent()->has('data') // If parent has no `data` than parent is a ResourceCollection
        ) {
            if (! property_exists($object, 'id')) {
                throw new ValidationException('A resource object MUST contain an id');
            }

            if (is_object($object->id) or is_array($object->id)) {
                throw new ValidationException('Resource id cannot be an array or object');
            }

            $this->set('id', strval($object->id));
        }

        if (property_exists($object, 'meta')) {
            $this->set('meta', $this->create('Meta', $object->meta));
        }

        if (property_exists($object, 'attributes')) {
            $this->set('attributes', $this->create('Attributes', $object->attributes));
        }

        if (property_exists($object, 'relationships')) {
            $this->set('relationships', $this->create('RelationshipCollection', $object->relationships));
        }

        if (property_exists($object, 'links')) {
            $this->set('links', $this->create('ResourceItemLink', $object->links));
        }
    }
284259
protected function deserialize($data, $class, $format, Context $ctx = null)
    {
        if (!$ctx) {
            $ctx = DeserializationContext::create();
        }

        $obj = $this->container->get('serializer')->deserialize($data, $class, $format, $ctx);

        if ($ctx instanceof DeserializationContext) {
            if ($errors = $ctx->getValidationErrors()) {
                throw new ValidationException($errors);
            }
        }

        return $obj;
    }
1329506
private function isValidObjectInstance($object)
    {
        if (!is_null($this->classname) && !$this->isInstanceOrSubclassOf($object)) {
            return false;
        }

        return true;
    }
602484
protected function doValidateObject($object)
    {
        if ($object === null || (empty($object) && $object !==0 && $object !=='0') )
            throw new \InvalidArgumentException(sprintf(
                'Object can`t be empty, given: (%s).'
                , \Poirot\Std\flatten($object)
            ));
    }
971891
protected function parse($object)
    {
        if (! is_object($object)) {
            throw new ValidationException(
                'DocumentLink has to be an object, "' . gettype($object) . '" given.'
            );
        }

        $links = get_object_vars($object);

        if (array_key_exists('self', $links)) {
            if (! is_string($links['self']) and ! is_object($links['self'])) {
                throw new ValidationException(
                    'property "self" has to be a string or object, "' .
                    gettype($links['self']) . '" given.'
                );
            }

            $this->setLink('self', $links['self']);

            unset($links['self']);
        }

        if (array_key_exists('related', $links)) {
            if (! is_string($links['related']) and ! is_object($links['related'])) {
                throw new ValidationException(
                    'property "related" has to be a string or object, "' .
                    gettype($links['related']) . '" given.'
                );
            }

            $this->setLink('related', $links['related']);

            unset($links['related']);
        }

        // Pagination links, if data in parent attributes exists
        if ($this->getParent()->has('data')) {
            if (array_key_exists('first', $links)) {
                $this->setPaginationLink('first', $links['first']);

                unset($links['first']);
            }

            if (array_key_exists('last', $links)) {
                $this->setPaginationLink('last', $links['last']);

                unset($links['last']);
            }

            if (array_key_exists('prev', $links)) {
                $this->setPaginationLink('prev', $links['prev']);

                unset($links['prev']);
            }

            if (array_key_exists('next', $links)) {
                $this->setPaginationLink('next', $links['next']);

                unset($links['next']);
            }
        }

        // custom links
        foreach ($links as $name => $value) {
            $this->setLink($name, $value);
        }
    }
280994
public function validateData(\Magento\Framework\DataObject $dataObject)
    {
        $result = [];
        $fromDate = $toDate = null;

        if ($dataObject->hasFromDate() && $dataObject->hasToDate()) {
            $fromDate = $dataObject->getFromDate();
            $toDate = $dataObject->getToDate();
        }

        if ($fromDate && $toDate) {
            $fromDate = $this->dateFilter->filter($fromDate);
            $toDate = $this->dateFilter->filter($toDate);

            if ($fromDate > $toDate) {
                $result[] = __('End Date must follow Start Date.');
            }
        }

        return !empty($result) ? $result : true;
    }
82213
private function serializeBodyObject($object): string
    {
        try {
            return $this->serializer->serialize($object, 'atol_client', $this->getSerializeBodyObjectContext());
        } catch (\RuntimeException $exception) {
            throw ParseException::becauseOfRuntimeException($exception, ParseException::REQUEST);
        }
    }
1002783
private static function isValidObject($object): bool {
        if (null === $object) {
            return false;
        }
        if (!\is_object($object)) {
            return false;
        }
        return true;
    }
87381
protected function parseObjectData($class, $object){
        $result = [];
        $reflection = new \ReflectionClass($class);
        foreach ($reflection->getProperties() as $property){
            $propertyName = $property->name;
            $method = 'get'.ucfirst($propertyName);
            $result[$propertyName] = $reflection->hasMethod($method) ? $object->$method() : null;
        }
        return $result;
    }
1000421
protected function _readHasErrors($object)
    {
        if ($object instanceof EntityInterface && $object->hasErrors()) {
            return true;
        }

        if (is_array($object)) {
            foreach ($object as $value) {
                if ($this->_readHasErrors($value)) {
                    return true;
                }
            }
        }

        return false;
    }
456306
protected function parse($object)
    {
        if (! is_object($object)) {
            throw new ValidationException('Link has to be an object, "' . gettype($object) . '" given.');
        }

        $links = get_object_vars($object);

        if (! array_key_exists('about', $links)) {
            throw new ValidationException('ErrorLink MUST contain these properties: about');
        }

        if (! is_string($links['about']) and ! is_object($links['about'])) {
            throw new ValidationException('Link has to be an object or string, "' . gettype($links['about']) . '" given.');
        }

        if (is_string($links['about'])) {
            $this->set('about', strval($links['about']));
        } else {
            $this->set('about', $this->create('Link', $links['about']));
        }

        unset($links['about']);

        // custom links
        foreach ($links as $name => $value) {
            $this->setLink($name, $value);
        }
    }
1000692
private static function validateArray(array $object): bool
    {
        return (count($object) === 2)
            && (isset($object[0]))
            && (is_object($object[0]))
            && (isset($object[1]))
            && (is_string($object[1]))
            && ($object[0] instanceof $object[1]);
    }
955500
private function validateDataType($object, string $path)
    {
        if (!is_object($object)) {
            $exception = SerializerLogicException::createWrongDataType(gettype($object), $path);

            $this->logger->error('serialize: {exception}', ['exception' => $exception->getMessage()]);

            throw $exception;
        }
    }
573356
public function trySet($object) {
      /** if we're passed one argument pluck its object **/
      if (sizeof($object) == 1)
        $object = $object[0];
       if (is_array($object)) {
         /** either its a verb, text or attribute **/
         /** we need to find type by its name **/
              
         /** create the object and any additional attributes **/
         /** attributes are set in "attributes" field of array **/
         $this->handleAttributes($object); 
       } elseif (is_object($object)) {
         
        /** object based initialization **/       
        $this->setVerb($object); 
       } elseif (is_string($object)) {
          /** polymorphic style initialization **/
          /** first parameter needs to be the name of the instance **/
          /** following are attributes **/
        $args = array_slice($object[1], $object[sizeof($object) - 1]);
            
       } else {
          throw new \CatapultApiException("Invalid input for baML must be either string, instance or associative array");
       }
    }
1018430
public function isValueObject($object)
    {
        if (!is_string($object)) {
            $object = get_class($object);
        }

        return array_key_exists($object, $this->valueClasses);
    }
1055609
protected function parse($object)
    {
        if (! is_array($object)) {
            throw new ValidationException('Resources for a collection has to be in an array, "' . gettype($object) . '" given.');
        }

        if (count($object) > 0) {
            foreach ($object as $resource) {
                $this->set('', $this->parseResource($resource));
            }
        }
    }