/** * This constructor initializes the property to an undefined value. * * @access public * @param mixed $data any data to pre-set */ public function __construct($data = array()) { $data = Core\Convert::toDictionary($data); $data = array_change_key_case($data, CASE_LOWER); foreach (get_object_vars($this) as $name => $value) { $this->{$name} = array_key_exists($name, $data) ? $data[$name] : Core\Data\Undefined::instance(); } }
/** * This constructor initializes the property to an undefined value. * * @access public * @param mixed $data any data to pre-set */ public function __construct($data = array()) { $properties = get_object_vars($this); $data = Core\Convert::toDictionary($data); foreach ($properties as $name => $value) { $this->{$name} = array_key_exists($name, $data) ? $data[$name] : Core\Data\Undefined::instance(); } }
/** * This method returns the JSON schema for the specified input. * * @access public * @static * @param mixed $schema the JSON schema to be loaded * @return array the JSON schema */ public static function resolveJSONSchema($schema) { if (is_string($schema)) { $components = preg_split('/(\\\\|_)+/', trim($schema, '\\')); $file = Bootstrap::rootPath() . implode(DIRECTORY_SEPARATOR, $components) . '.json'; $schema = Config\JSON\Reader::load(new IO\File($file))->read(); } $schema = Core\Convert::toDictionary($schema); if (isset($schema['$ref'])) { $result = MappingService\Data\Model\JSON\Helper::resolveJSONSchema($schema['$ref']); if (isset($schema['properties'])) { $result = array_merge($result, $schema['properties']); } return $result; } return $schema; }