Skip to content

Commit

Permalink
Fix: Remove unnecessary condition
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Jan 21, 2022
1 parent 331f01a commit 528d24f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 32 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -15,6 +15,7 @@ For a full diff see [`2.0.0...2.1.0`][2.0.0...2.1.0].
### Changed

- Adjusted `SchemaNormalizer` to support `anyOf` ([#623]), by [@localheinz]
- Stopped checking whether `type` property in schema is set to `array` or `object` ([#632]), by [@localheinz]

## [`2.0.0`][2.0.0]

Expand Down Expand Up @@ -461,6 +462,7 @@ For a full diff see [`5d8b3e2...0.1.0`][5d8b3e2...0.1.0].
[#618]: https://github.com/ergebnis/json-normalizer/pull/618
[#619]: https://github.com/ergebnis/json-normalizer/pull/619
[#623]: https://github.com/ergebnis/json-normalizer/pull/623
[#632]: https://github.com/ergebnis/json-normalizer/pull/632

[@BackEndTea]: https://github.com/BackEndTea
[@dependabot]: https://github.com/dependabot
Expand Down
32 changes: 0 additions & 32 deletions src/SchemaNormalizer.php
Expand Up @@ -131,13 +131,6 @@ private function normalizeArray(
$schema,
);

/**
* @see https://json-schema.org/understanding-json-schema/reference/array.html
*/
if (!self::describesType('array', $schema)) {
return $data;
}

/**
* @see https://json-schema.org/understanding-json-schema/reference/array.html#items
*/
Expand Down Expand Up @@ -179,13 +172,6 @@ private function normalizeObject(
$schema,
);

/**
* @see https://json-schema.org/understanding-json-schema/reference/object.html
*/
if (!self::describesType('object', $schema)) {
return $data;
}

/**
* @see https://json-schema.org/understanding-json-schema/reference/object.html#properties
*/
Expand Down Expand Up @@ -298,22 +284,4 @@ private function resolveSchema(

return $schema;
}

/**
* @see https://json-schema.org/understanding-json-schema/reference/type.html
*/
private static function describesType(
string $type,
\stdClass $schema
): bool {
if (!\property_exists($schema, 'type')) {
return false;
}

if ($schema->type === $type) {
return true;
}

return \is_array($schema->type) && \in_array($type, $schema->type, true);
}
}

0 comments on commit 528d24f

Please sign in to comment.