1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * Copyright (c) 2018-2020 Andreas Möller
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE.md file that was distributed with this source code.
10
 *
11
 * @see https://github.com/ergebnis/composer-normalize
12
 */
13

14
namespace Ergebnis\Composer\Normalize;
15

16
use Composer\Composer;
17
use Composer\Factory;
18
use Composer\IO;
19
use Composer\Plugin;
20
use Ergebnis\Json\Normalizer;
21
use Ergebnis\Json\Printer;
22
use Localheinz\Diff;
23

24
final class NormalizePlugin implements Plugin\Capability\CommandProvider, Plugin\Capable, Plugin\PluginInterface
25
{
26 0
    public function activate(Composer $composer, IO\IOInterface $io): void
27
    {
28
    }
29

30 0
    public function deactivate(Composer $composer, IO\IOInterface $io): void
31
    {
32
    }
33

34 0
    public function uninstall(Composer $composer, IO\IOInterface $io): void
35
    {
36
    }
37

38 0
    public function getCapabilities(): array
39
    {
40
        return [
41 0
            Plugin\Capability\CommandProvider::class => self::class,
42
        ];
43
    }
44

45 2
    public function getCommands(): array
46
    {
47
        return [
48 2
            new Command\NormalizeCommand(
49 2
                new Factory(),
50 2
                new Normalizer\Vendor\Composer\ComposerJsonNormalizer(\sprintf(
51 2
                    'file://%s',
52 2
                    \realpath(__DIR__ . '/../resource/schema.json')
53
                )),
54 2
                new Normalizer\Format\Formatter(new Printer\Printer()),
55 2
                new Diff\Differ(new Diff\Output\StrictUnifiedDiffOutputBuilder([
56 2
                    'fromFile' => 'original',
57
                    'toFile' => 'normalized',
58
                ]))
59
            ),
60
        ];
61
    }
62
}

Read our documentation on viewing source code .

Loading