Creates a ClassValidationArray filled with ProcessedOutGoingSMS given an array of stdClass.
@param array $stdClassArray An array of stdClass OutGoingSMS.
@return ClassValidationArray Filled with ProcessedOutGoingSMS.
354311
public static function createProcessedOutGoingSMSFromStdClassArray(array $stdClassArray): ClassValidationArray
    {
        $array = new ClassValidationArray(ProcessedOutGoingSMS::class);
        foreach ($stdClassArray as $stdClass) {
            $array[]= self::createProcessedOutGoingSMSFromStdClass($stdClass);
        }
        return $array;
    }
952847
public function stdClassToArrayCheckValues(array $array)
    {
        foreach ($array as $key => $value) {
            if ($value instanceof \stdClass) {
                $array[ $key ] = $this->stdClassToArray($value);
            } else if (is_array($value)) {
                $array[ $key ] = $this->stdClassToArrayCheckValues($value);
            } else {
                $array[ $key ] = $value;
            }
        }

        return $array;
    }
423517
public static function createFromStdClass(stdClass $class)
	{
		$hash = isset($class->hash) ? $class->hash : null;
		$scope = isset($class->scope) ? $class->scope : null;
		$action = isset($class->action) ? $class->action : null;
		$data = isset($class->data) ? $class->data : null;
		$state = isset($class->state) ? $class->state : null;
		$ip = isset($class->ip) ? $class->ip : null;
		$useragent = isset($class->useragent) ? $class->useragent : null;
		$createdAt = isset($class->created_at) ? $class->created_at : null;

		return new Action($hash, $scope, $action, $data, $state, $ip, $useragent, $createdAt);
	}
988780
public function jsonSerialize(): stdClass
    {
        $object = (object)object_get_properties($this, $this instanceof DynamicEntity);

        /** @var Event\ToJson $event */
        $event = $this->dispatchEvent(new Event\ToJson($this, $object));
        $data = i\type_check($event->getPayload(), stdClass::class, new UnexpectedValueException());

        return $data;
    }
1063712
protected function objectToArray(stdClass $data = null)
    {
        if (null !== $data) {
            $data = (array) $data;
            foreach ($data as $key => $value) {
                if ($value instanceof stdClass) {
                    $data[$key] = $this->objectToArray($value);
                }
            }
        }

        return $data;
    }
199563
public static function validate_class_inheritance(array $relation): array
    {
        return array_filter($relation, function($className)
        {
            if (
                ClassInfo::exists($className)
                && (is_a(singleton($className), ElementBase::class))
            ) {
                return $className;
            }
            user_error('Your element needs to extend from ' . ElementBase::class, E_USER_WARNING);
        });
    }
316380
public function current()
    {
        try {
            return $this->table->current();
        } catch (DataSourceException $e) {
            throw new DataStreamValidationException($e->getMessage());
        } catch (FieldValidationException $e) {
            throw new DataStreamValidationException($e->getMessage());
        }
    }
983594
public function validate($arr)
    {
        $returnValue = new ValidatorResult();
        $this->currentNode = 'root';

        try {
            $this->validateSchemaBeginsWithRootKey(new CustomArrayObject($this->schema));

            if ($this->strictMode) {
                $this->validateExcessiveKeysAbsent(new CustomArrayObject($this->schema['root']), $arr);
            }

            $this->validateNode('root', new CustomArrayObject($this->schema), $arr);
        } catch (Exception $exc) {
            $this->getLogger()->error($exc->getMessage());

            $returnValue->setError($exc->getCode(), $this->getCurrentNode(), $exc->getMessage());
            $returnValue->setLog($this->getLogger()->getLog());
        }

        return $returnValue;
    }
242669
public function validateObject($object) {
        if (!$object instanceof SerialisableObject) {
            throw new ClassNotSerialisableException(get_class($object));
        }

        $classAnnotations = ClassAnnotationParser::instance()->parse($object);

        $validationFields = $classAnnotations->getFieldAnnotationsForMatchingTag("validation");

        $validationErrors = array();

        foreach ($validationFields as $field => $annotation) {

            $value = $object->__getSerialisablePropertyValue($field);

            foreach ($annotation[0]->getValues() as $validatorString) {

                $explodedValidator = explode("(", $validatorString);
                $validatorKey = trim($explodedValidator[0]);

                // Gather validator args if supplied.
                $validatorArgs = array();
                if (sizeof($explodedValidator) > 1) {
                    $argsCSV = explode(")", $explodedValidator[1]);
                    $args = explode("|", $argsCSV[0]);

                    foreach ($args as $arg) {
                        $validatorArgs[] = trim($arg);
                    }
                }

                $validator = isset($this->validators[$validatorKey]) ? $this->validators[$validatorKey] : null;
                if (isset($validator)) {
                    $valid = $validator->validateObjectFieldValue($value, $field, $object, $validatorArgs, $validatorKey);

                    if ($valid !== true) {
                        if (!isset($validationErrors[$field])) $validationErrors[$field] = array();
                        $message = preg_replace_callback("/\\$([0-9])/", function ($matches) use ($validatorArgs) {
                            return $validatorArgs[$matches[1] - 1];
                        }, $validator->getValidationMessage());
                        $validationErrors[$field][$validatorKey] = new FieldValidationError($field, $validatorKey, $message);
                    }

                } else {
                    throw new InvalidValidatorException($validatorKey, $field, $object);
                }


            }

        }

        return $validationErrors;


    }
363327
public static function toObject($array, $class = \stdClass::class)
    {
        $object = new $class;

        foreach ($array as $name => $value) {
            $name = trim($name);

            if (!$name || is_numeric($name)) {
                continue;
            }

            $object->$name = \is_array($value) ? self::toObject($value) : $value;
        }

        return $object;
    }
659190
protected function readSchema(): \stdClass
    {
        $schema = $this->getEmptyResult();

        try {
            $schema = $this->getSchema()->read();
        } catch (InvalidArgumentException $e) {
            $this->errors[] = $e->getMessage();

            throw new JsonValidationException("Schema file `{$this->schema->getSchemaPath()}` cannot be read", 0, $e);
        }

        return $schema;
    }
1201281
public static function fromArray($array)
    {
        $values   = $array['value'];
        $property = $array['property'];

        if (!(isset($values, $property))) {
            throw new DcGeneralInvalidArgumentException('Invalid filter array provided  ' . \var_export($array, true));
        }

        return new static($property, $values);
    }
531057
static function array2object(array $arr, $class = 'StdClass')
    {
        $obj = new $class;
        foreach ($arr as $key => $value) {
            $obj->{$key} = is_array($value) ? static::array2object($value, $class) : $value;
        }
        return $obj;
    }
970278
public function backendListArrayToMultiAssocArray(stdClass $list)
    {
        $ret = array();

        if ( isset($list->ArrayOfString) ) {
            foreach ( $list->ArrayOfString as $a ) {
                if ( is_array($a) ) {      // 1 template only
                    $o         = new StdClass();
                    $o->string = $a;
                } else {                 // 2 or more templates
                    $o = $a;
                }
                unset($a);

                if ( isset($o->string) ) {
                    $date1 = DateTime::createFromFormat(DateTime::RFC1123 , $o->string[ 3 ]);
                    $date2 = DateTime::createFromFormat(DateTime::RFC1123 , $o->string[ 1 ]);
                    $ret[] = array(
                        'filename'   => $o->string[ 0 ] ,
                        'fileSize'   => ( integer ) $o->string[ 2 ] ,
                        'createTime' => ( integer ) $date1->getTimestamp() ,
                        'modifyTime' => ( integer ) $date2->getTimestamp() ,
                    );
                    unset($date1 , $date2);
                }
            }
        }

        return $ret;
    }
828875
protected function validateArray(&$document_data, &$data, array $data_pointer, array $parent_data_pointer, ISchema $document, $schema, ValidationResult $bag): bool
    {
        $ok = true;

        // minItems
        if (property_exists($schema, 'minItems')) {
            if (!is_int($schema->minItems)) {
                throw new SchemaKeywordException(
                    $schema,
                    'minItems',
                    $schema->minItems,
                    "'minItems' keyword must be an integer, " . gettype($schema->minItems) . " given"
                );
            }
            if ($schema->minItems < 0) {
                throw new SchemaKeywordException(
                    $schema,
                    'minItems',
                    $schema->minItems,
                    "'minItems' keyword must be positive, " . $schema->minItems . " given"
                );
            }
            if (($count = count($data)) < $schema->minItems) {
                $ok = false;
                $bag->addError(new ValidationError($data, $data_pointer, $parent_data_pointer, $schema, 'minItems', [
                    'min' => $schema->minItems,
                    'count' => $count,
                ]));
                if ($bag->isFull()) {
                    return false;
                }
            }
            unset($count);
        }

        // maxItems
        if (property_exists($schema, 'maxItems')) {
            if (!is_int($schema->maxItems)) {
                throw new SchemaKeywordException(
                    $schema,
                    'maxItems',
                    $schema->maxItems,
                    "'maxItems' keyword must be an integer, " . gettype($schema->maxItems) . " given"
                );
            }
            if ($schema->maxItems < 0) {
                throw new SchemaKeywordException(
                    $schema,
                    'maxItems',
                    $schema->maxItems,
                    "'maxItems' keyword must be positive, " . $schema->maxItems . " given"
                );
            }
            if (($count = count($data)) > $schema->maxItems) {
                $ok = false;
                $bag->addError(new ValidationError($data, $data_pointer, $parent_data_pointer, $schema, 'maxItems', [
                    'max' => $schema->maxItems,
                    'count' => $count,
                ]));
                if ($bag->isFull()) {
                    return false;
                }
            }
            unset($count);
        }

        // uniqueItems
        if (property_exists($schema, 'uniqueItems')) {
            if (!is_bool($schema->uniqueItems)) {
                throw new SchemaKeywordException(
                    $schema,
                    'uniqueItems',
                    $schema->uniqueItems,
                    "'uniqueItems' keyword must be a boolean, " . gettype($schema->uniqueItems) . " given"
                );
            }
            if ($schema->uniqueItems) {
                $valid = true;
                $count = count($data);
                $dup = null;
                for ($i = 0; $i < $count - 1; $i++) {
                    for ($j = $i + 1; $j < $count; $j++) {
                        if ($this->helper->equals($data[$i], $data[$j])) {
                            $valid = false;
                            $dup = $data[$i];
                            break 2;
                        }
                    }
                }
                if (!$valid) {
                    $ok = false;
                    $bag->addError(new ValidationError($data, $data_pointer, $parent_data_pointer, $schema, 'uniqueItems', [
                        'duplicate' => $dup,
                    ]));
                    if ($bag->isFull()) {
                        return false;
                    }
                }
                unset($valid, $count, $dup);
            }
        }

        // contains
        if (property_exists($schema, 'contains')) {
            $valid = false;
            $newbag = new ValidationResult(1);
            $errors = [];
            foreach ($data as $i => &$value) {
                $data_pointer[] = $i;
                $valid = $this->validateSchema($document_data, $value, $data_pointer, $parent_data_pointer, $document, $schema->contains, $newbag);
                array_pop($data_pointer);
                if ($valid) {
                    break;
                }
                $errors = array_merge($errors, $newbag->getErrors());
                $newbag->clear();
            }
            unset($value, $newbag);
            if (!$valid) {
                $ok = false;
                $bag->addError(new ValidationError($data, $data_pointer, $parent_data_pointer, $schema, 'contains', [], $errors));
                if ($bag->isFull()) {
                    return false;
                }
            }
            unset($valid, $errors);
        }

        // items, additionalItems
        if (property_exists($schema, 'items')) {
            if (is_array($schema->items)) {
                $count = count($schema->items);
                $data_count = count($data);
                $max = min($count, $data_count);
                for ($i = 0; $i < $max; $i++) {
                    $data_pointer[] = $i;
                    $valid = $this->validateSchema($document_data, $data[$i], $data_pointer, $parent_data_pointer, $document, $schema->items[$i], $bag);
                    array_pop($data_pointer);
                    if (!$valid) {
                        $ok = false;
                        if ($bag->isFull()) {
                            return false;
                        }
                    }
                }
                if ($max < $data_count && property_exists($schema, 'additionalItems')) {
                    if (!is_bool($schema->additionalItems) && !is_object($schema->additionalItems)) {
                        throw new SchemaKeywordException(
                            $schema,
                            'additionalItems',
                            $schema->additionalItems,
                            "'additionalItems' keyword must be a boolean or an object, " . gettype($schema->additionalItems) . " given"
                        );
                    }
                    for ($i = $max; $i < $data_count; $i++) {
                        $data_pointer[] = $i;
                        $valid = $this->validateSchema($document_data, $data[$i], $data_pointer, $parent_data_pointer, $document, $schema->additionalItems, $bag);
                        array_pop($data_pointer);
                        if (!$valid) {
                            $ok = false;
                            if ($bag->isFull()) {
                                return false;
                            }
                        }
                    }
                }
                unset($max, $count, $data_count);
            } else {
                $count = count($data);
                for ($i = 0; $i < $count; $i++) {
                    $data_pointer[] = $i;
                    $valid = $this->validateSchema($document_data, $data[$i], $data_pointer, $parent_data_pointer, $document, $schema->items, $bag);
                    array_pop($data_pointer);
                    if (!$valid) {
                        $ok = false;
                        if ($bag->isFull()) {
                            return false;
                        }
                    }
                }
            }
        }

        return $ok;
    }
382249
public static function toObject($array, $class = 'stdClass')
    {
        $object = new $class();

        foreach ($array as $k => $v) {
            if (is_array($v)) {
                $object->$k = static::toObject($v, $class);
            } else {
                $object->$k = $v;
            }
        }

        return $object;
    }
132948
public static function validateArray(array $array) {
        $reflection =  new ReflectionClass(get_called_class());
        $allowedValues = $reflection->getConstants();
        foreach($array as $element) {
            if (!in_array($element, $allowedValues)) {
                throw new InvalidArgumentException(sprintf(
                    '%s is not a valid %s',
                    $element,
                    get_called_class()
                ));
            }
        }
    }