Skip to content

Commit

Permalink
Enhancement: Compose SchemaNormalizer into ComposerJsonNormalizer
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Jan 13, 2018
1 parent bae8e21 commit 0117001
Show file tree
Hide file tree
Showing 4 changed files with 862 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ The `ComposerJsonNormalizer` composes normalizers provided by [`localheinz/json-

* [`Localheinz\Json\Normalizer\AutoFormatNormalizer`](https://github.com/localheinz/json-normalizer#autoformatnormalizer)
* [`Localheinz\Json\Normalizer\ChainNormalizer`](https://github.com/localheinz/json-normalizer#chainnormalizer)
* [`Localheinz\Json\Normalizer\SchemaNormalizer`](https://github.com/localheinz/json-normalizer#schemanormalizer)

as well as the following normalizers provided by this package:

Expand Down
4 changes: 3 additions & 1 deletion src/Normalizer/ComposerJsonNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Localheinz\Json\Normalizer\AutoFormatNormalizer;
use Localheinz\Json\Normalizer\ChainNormalizer;
use Localheinz\Json\Normalizer\NormalizerInterface;
use Localheinz\Json\Normalizer\SchemaNormalizer;

final class ComposerJsonNormalizer implements NormalizerInterface
{
Expand All @@ -24,9 +25,10 @@ final class ComposerJsonNormalizer implements NormalizerInterface
*/
private $normalizer;

public function __construct()
public function __construct(string $schemaUri = 'https://getcomposer.org/schema.json')
{
$this->normalizer = new AutoFormatNormalizer(new ChainNormalizer(
new SchemaNormalizer($schemaUri),
new BinNormalizer(),
new ConfigHashNormalizer(),
new PackageHashNormalizer()
Expand Down
Loading

0 comments on commit 0117001

Please sign in to comment.