Joli\Jane\Normalizer\JsonSchemaNormalizer::normalize PHP Method

normalize() public method

public normalize ( $object, $format = null, array $context = [] )
$context array
    public function normalize($object, $format = null, array $context = [])
    {
        $data = new \stdClass();
        if (null !== $object->getId()) {
            $data->{'id'} = $object->getId();
        }
        if (null !== $object->getDollarSchema()) {
            $data->{'$schema'} = $object->getDollarSchema();
        }
        if (null !== $object->getTitle()) {
            $data->{'title'} = $object->getTitle();
        }
        if (null !== $object->getDescription()) {
            $data->{'description'} = $object->getDescription();
        }
        if (null !== $object->getDefault()) {
            $data->{'default'} = $object->getDefault();
        }
        if (null !== $object->getMultipleOf()) {
            $data->{'multipleOf'} = $object->getMultipleOf();
        }
        if (null !== $object->getMaximum()) {
            $data->{'maximum'} = $object->getMaximum();
        }
        if (null !== $object->getExclusiveMaximum()) {
            $data->{'exclusiveMaximum'} = $object->getExclusiveMaximum();
        }
        if (null !== $object->getMinimum()) {
            $data->{'minimum'} = $object->getMinimum();
        }
        if (null !== $object->getExclusiveMinimum()) {
            $data->{'exclusiveMinimum'} = $object->getExclusiveMinimum();
        }
        if (null !== $object->getMaxLength()) {
            $data->{'maxLength'} = $object->getMaxLength();
        }
        if (null !== $object->getMinLength()) {
            $data->{'minLength'} = $object->getMinLength();
        }
        if (null !== $object->getPattern()) {
            $data->{'pattern'} = $object->getPattern();
        }
        if (null !== $object->getAdditionalItems()) {
            $value = $object->getAdditionalItems();
            if (is_bool($object->getAdditionalItems())) {
                $value = $object->getAdditionalItems();
            }
            if (is_object($object->getAdditionalItems())) {
                $value = $this->serializer->serialize($object->getAdditionalItems(), 'raw', $context);
            }
            $data->{'additionalItems'} = $value;
        }
        if (null !== $object->getItems()) {
            $value_1 = $object->getItems();
            if (is_object($object->getItems())) {
                $value_1 = $this->serializer->serialize($object->getItems(), 'raw', $context);
            }
            if (is_array($object->getItems())) {
                $values = [];
                foreach ($object->getItems() as $value_2) {
                    $values[] = $this->serializer->serialize($value_2, 'raw', $context);
                }
                $value_1 = $values;
            }
            $data->{'items'} = $value_1;
        }
        if (null !== $object->getMaxItems()) {
            $data->{'maxItems'} = $object->getMaxItems();
        }
        if (null !== $object->getMinItems()) {
            $data->{'minItems'} = $object->getMinItems();
        }
        if (null !== $object->getUniqueItems()) {
            $data->{'uniqueItems'} = $object->getUniqueItems();
        }
        if (null !== $object->getMaxProperties()) {
            $data->{'maxProperties'} = $object->getMaxProperties();
        }
        if (null !== $object->getMinProperties()) {
            $data->{'minProperties'} = $object->getMinProperties();
        }
        if (null !== $object->getRequired()) {
            $values_1 = [];
            foreach ($object->getRequired() as $value_3) {
                $values_1[] = $value_3;
            }
            $data->{'required'} = $values_1;
        }
        if (null !== $object->getAdditionalProperties()) {
            $value_4 = $object->getAdditionalProperties();
            if (is_bool($object->getAdditionalProperties())) {
                $value_4 = $object->getAdditionalProperties();
            }
            if (is_object($object->getAdditionalProperties())) {
                $value_4 = $this->serializer->serialize($object->getAdditionalProperties(), 'raw', $context);
            }
            $data->{'additionalProperties'} = $value_4;
        }
        if (null !== $object->getDefinitions()) {
            $values_2 = new \stdClass();
            foreach ($object->getDefinitions() as $key => $value_5) {
                $values_2->{$key} = $this->serializer->serialize($value_5, 'raw', $context);
            }
            $data->{'definitions'} = $values_2;
        }
        if (null !== $object->getProperties()) {
            $values_3 = new \stdClass();
            foreach ($object->getProperties() as $key_1 => $value_6) {
                $values_3->{$key_1} = $this->serializer->serialize($value_6, 'raw', $context);
            }
            $data->{'properties'} = $values_3;
        }
        if (null !== $object->getPatternProperties()) {
            $values_4 = new \stdClass();
            foreach ($object->getPatternProperties() as $key_2 => $value_7) {
                $values_4->{$key_2} = $this->serializer->serialize($value_7, 'raw', $context);
            }
            $data->{'patternProperties'} = $values_4;
        }
        if (null !== $object->getDependencies()) {
            $values_5 = new \stdClass();
            foreach ($object->getDependencies() as $key_3 => $value_8) {
                $value_9 = $value_8;
                if (is_object($value_8)) {
                    $value_9 = $this->serializer->serialize($value_8, 'raw', $context);
                }
                if (is_array($value_8)) {
                    $values_6 = [];
                    foreach ($value_8 as $value_10) {
                        $values_6[] = $value_10;
                    }
                    $value_9 = $values_6;
                }
                $values_5->{$key_3} = $value_9;
            }
            $data->{'dependencies'} = $values_5;
        }
        if (null !== $object->getEnum()) {
            $values_7 = [];
            foreach ($object->getEnum() as $value_11) {
                $values_7[] = $value_11;
            }
            $data->{'enum'} = $values_7;
        }
        if (null !== $object->getType()) {
            $value_12 = $object->getType();
            if (!is_null($object->getType())) {
                $value_12 = $object->getType();
            }
            if (is_array($object->getType())) {
                $values_8 = [];
                foreach ($object->getType() as $value_13) {
                    $values_8[] = $value_13;
                }
                $value_12 = $values_8;
            }
            $data->{'type'} = $value_12;
        }
        if (null !== $object->getFormat()) {
            $data->{'format'} = $object->getFormat();
        }
        if (null !== $object->getAllOf()) {
            $values_9 = [];
            foreach ($object->getAllOf() as $value_14) {
                $values_9[] = $this->serializer->serialize($value_14, 'raw', $context);
            }
            $data->{'allOf'} = $values_9;
        }
        if (null !== $object->getAnyOf()) {
            $values_10 = [];
            foreach ($object->getAnyOf() as $value_15) {
                $values_10[] = $this->serializer->serialize($value_15, 'raw', $context);
            }
            $data->{'anyOf'} = $values_10;
        }
        if (null !== $object->getOneOf()) {
            $values_11 = [];
            foreach ($object->getOneOf() as $value_16) {
                $values_11[] = $this->serializer->serialize($value_16, 'raw', $context);
            }
            $data->{'oneOf'} = $values_11;
        }
        if (null !== $object->getNot()) {
            $data->{'not'} = $this->serializer->serialize($object->getNot(), 'raw', $context);
        }
        return $data;
    }