Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
Allow injecting classname resolver into descritpion factory
Browse files Browse the repository at this point in the history
  • Loading branch information
kleijnweb committed Aug 24, 2018
1 parent 490cd4e commit 138051e
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/Description/DescriptionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use KleijnWeb\PhpApi\Descriptions\Description\Builder\RamlBuilder;
use KleijnWeb\PhpApi\Descriptions\Description\Document\Definition\RefResolver\RefResolver;
use KleijnWeb\PhpApi\Descriptions\Description\Document\Document;
use KleijnWeb\PhpApi\Descriptions\Hydrator\ClassNameResolver;

/**
* @author John Kleijn <john@kleijnweb.nl>
Expand All @@ -26,14 +27,21 @@ class DescriptionFactory
*/
private $type;

/**
* @var ClassNameResolver
*/
private $classNameResolver;

/**
* DescriptionFactory constructor.
*
* @param string $type
* @param string $type
* @param ClassNameResolver|null $classNameResolver
*/
public function __construct(string $type = self::BUILDER_OPEN_API)
public function __construct(string $type = self::BUILDER_OPEN_API, ClassNameResolver $classNameResolver = null)
{
$this->type = $type;
$this->type = $type;
$this->classNameResolver = $classNameResolver;
}

/**
Expand All @@ -51,7 +59,8 @@ public function create(string $uri, \stdClass $definition): Description
new Document(
$uri,
(new RefResolver($definition, $uri))->resolve()
)
),
$this->classNameResolver
)
)->build();
case self::BUILDER_RAML:
Expand All @@ -60,7 +69,8 @@ public function create(string $uri, \stdClass $definition): Description
new Document(
$uri,
$definition
)
),
$this->classNameResolver
)
)->build();
default:
Expand Down

0 comments on commit 138051e

Please sign in to comment.