summaryrefslogtreecommitdiff
path: root/server/vendor/php-opencloud/common/src/Common/JsonSchema/Schema.php
diff options
context:
space:
mode:
authorEoleDev <EoleDev@outlook.fr>2016-04-14 16:24:44 +0200
committerEoleDev <EoleDev@outlook.fr>2016-04-14 16:24:44 +0200
commit24bb5fefbdf93ce0969b7f56cc46c459ebb82a95 (patch)
tree531fc8b774c035040774234efba780a3d4fe9242 /server/vendor/php-opencloud/common/src/Common/JsonSchema/Schema.php
parent646af6fd4d14c5b5edb1372e5f68ed9bdc35b3d2 (diff)
Mise a jour et nettoyage depot
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.php75
1 files changed, 0 insertions, 75 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 e1e3f65..0000000
--- a/server/vendor/php-opencloud/common/src/Common/JsonSchema/Schema.php
+++ /dev/null
@@ -1,75 +0,0 @@
-<?php declare(strict_types=1);
-
-namespace OpenCloud\Common\JsonSchema;
-
-use JsonSchema\Validator;
-
-class Schema
-{
- /** @var object */
- private $body;
-
- /** @var Validator */
- private $validator;
-
- public function __construct($body, Validator $validator = null)
- {
- $this->body = (object) $body;
- $this->validator = $validator ?: new Validator();
- }
-
- public function getPropertyPaths(): array
- {
- $paths = [];
-
- foreach ($this->body->properties as $propertyName => $property) {
- $paths[] = sprintf("/%s", $propertyName);
- }
-
- return $paths;
- }
-
- public function normalizeObject($subject, array $aliases): \stdClass
- {
- $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(): bool
- {
- return $this->validator->isValid();
- }
-
- public function getErrors(): array
- {
- return $this->validator->getErrors();
- }
-
- public function getErrorString(): string
- {
- $msg = "Provided values do not validate. Errors:\n";
-
- foreach ($this->getErrors() as $error) {
- $msg .= sprintf("[%s] %s\n", $error['property'], $error['message']);
- }
-
- return $msg;
- }
-}