diff --git a/src/WordPress/Blueprints/BlueprintParser.php b/src/WordPress/Blueprints/BlueprintParser.php index 28374406..8156ebdb 100644 --- a/src/WordPress/Blueprints/BlueprintParser.php +++ b/src/WordPress/Blueprints/BlueprintParser.php @@ -4,6 +4,7 @@ use InvalidArgumentException; use Opis\JsonSchema\Errors\ErrorFormatter; +use stdClass; use WordPress\Blueprints\Model\BlueprintBuilder; use WordPress\Blueprints\Model\DataClass\Blueprint; @@ -27,8 +28,13 @@ public function __construct( $this->mapper = $mapper; } + /** + * @param Blueprint|string|stdClass $raw_blueprint + * @return Blueprint + * @throws InvalidArgumentException if unsupported input type or json string can not be decoded + */ public function parse( $raw_blueprint ) { - if ( $raw_blueprint instanceof \stdClass ) { + if ( $raw_blueprint instanceof stdClass ) { return $this->fromObject( $raw_blueprint ); } @@ -46,17 +52,13 @@ public function parse( $raw_blueprint ) { return $this->fromBlueprint( $raw_blueprint ); } - if ( $raw_blueprint instanceof BlueprintBuilder ) { - return $this->fromBlueprint( $raw_blueprint->toBlueprint() ); - } - throw new InvalidArgumentException( - 'Unsupported $rawBlueprint type. Use a JSON string, a parsed JSON object, or a BlueprintBuilder instance.' + 'Unsupported $rawBlueprint type. Use a JSON string, a parsed JSON object, or a Blueprint instance.' ); } /** - * @param \stdClass $data + * @param stdClass $data */ public function fromObject( $data ) { $result = $this->validator->validate( $data );