diff options
| author | Eole <EoleDev@outlook.fr> | 2016-04-27 16:42:28 +0200 |
|---|---|---|
| committer | Eole <EoleDev@outlook.fr> | 2016-04-27 16:42:28 +0200 |
| commit | 49f416dc5061032e0514ea0cfeceaca37d13e432 (patch) | |
| tree | 1202ac2a6fa860b8929afdc886c94fc50bd0a1de /server/vendor/php-opencloud/common/src/Common/JsonSchema/Schema.php | |
| parent | c7edd70b5e5b0f5159c78ce3d924d4e7f60db816 (diff) | |
| parent | c9202d9113210981ae47df40511645da2ee140df (diff) | |
Merge branch 'develop' into Eole_Graph
Conflicts:
client/index.html
client/js/controllers/home/home.js
client/partials/home/home.html
Diffstat (limited to 'server/vendor/php-opencloud/common/src/Common/JsonSchema/Schema.php')
| -rw-r--r-- | server/vendor/php-opencloud/common/src/Common/JsonSchema/Schema.php | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/server/vendor/php-opencloud/common/src/Common/JsonSchema/Schema.php b/server/vendor/php-opencloud/common/src/Common/JsonSchema/Schema.php deleted file mode 100644 index a1cd380..0000000 --- a/server/vendor/php-opencloud/common/src/Common/JsonSchema/Schema.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php - -namespace OpenCloud\Common\JsonSchema; - -use JsonSchema\Validator; - -class Schema -{ - private $body; - private $validator; - - public function __construct($body, Validator $validator = null) - { - $this->body = (object) $body; - $this->validator = $validator ?: new Validator(); - } - - public function getPropertyPaths() - { - $paths = []; - - foreach ($this->body->properties as $propertyName => $property) { - $paths[] = sprintf("/%s", $propertyName); - } - - return $paths; - } - - public function normalizeObject($subject, array $aliases) - { - $out = new \stdClass; - - foreach ($this->body->properties as $propertyName => $property) { - $name = isset($aliases[$propertyName]) ? $aliases[$propertyName] : $propertyName; - if (isset($property->readOnly) && $property->readOnly === true) { - continue; - } elseif (property_exists($subject, $name)) { - $out->$propertyName = $subject->$name; - } elseif (property_exists($subject, $propertyName)) { - $out->$propertyName = $subject->$propertyName; - } - } - - return $out; - } - - public function validate($data) - { - $this->validator->check($data, $this->body); - } - - public function isValid() - { - return $this->validator->isValid(); - } - - public function getErrors() - { - return $this->validator->getErrors(); - } - - public function getErrorString() - { - $msg = "Provided values do not validate. Errors:\n"; - - foreach ($this->getErrors() as $error) { - $msg .= sprintf("[%s] %s\n", $error['property'], $error['message']); - } - - return $msg; - } -} |
