Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
48 / 48
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
DevToolsServiceProvider
100.00% covered (success)
100.00%
48 / 48
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 getFactories
100.00% covered (success)
100.00%
47 / 47
100.00% covered (success)
100.00%
1 / 1
1
 getExtensions
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5/**
6 * Fast Forward Development Tools for PHP projects.
7 *
8 * This file is part of fast-forward/dev-tools project.
9 *
10 * @author   Felipe SayĆ£o Lobato Abreu <github@mentordosnerds.com>
11 * @license  https://opensource.org/licenses/MIT MIT License
12 *
13 * @see      https://github.com/php-fast-forward/
14 * @see      https://github.com/php-fast-forward/dev-tools
15 * @see      https://github.com/php-fast-forward/dev-tools/issues
16 * @see      https://php-fast-forward.github.io/dev-tools/
17 * @see      https://datatracker.ietf.org/doc/html/rfc2119
18 */
19
20namespace FastForward\DevTools\ServiceProvider;
21
22use Composer\Plugin\Capability\CommandProvider;
23use FastForward\DevTools\Changelog\Manager\ChangelogManager;
24use FastForward\DevTools\Changelog\Manager\ChangelogManagerInterface;
25use FastForward\DevTools\Changelog\Parser\ChangelogParser;
26use FastForward\DevTools\Changelog\Parser\ChangelogParserInterface;
27use FastForward\DevTools\Composer\Capability\DevToolsCommandProvider;
28use FastForward\DevTools\Composer\Json\ComposerJson;
29use FastForward\DevTools\Composer\Json\ComposerJsonInterface;
30use FastForward\DevTools\Git\GitClient;
31use FastForward\DevTools\Git\GitClientInterface;
32use FastForward\DevTools\Changelog\Renderer\MarkdownRenderer;
33use FastForward\DevTools\Changelog\Renderer\MarkdownRendererInterface;
34use FastForward\DevTools\Changelog\Checker\UnreleasedEntryChecker;
35use FastForward\DevTools\Changelog\Checker\UnreleasedEntryCheckerInterface;
36use FastForward\DevTools\Console\CommandLoader\DevToolsCommandLoader;
37use FastForward\DevTools\Console\Formatter\LogLevelOutputFormatter;
38use FastForward\DevTools\Console\Logger\OutputFormatLogger;
39use FastForward\DevTools\Console\Logger\Processor\CommandInputProcessor;
40use FastForward\DevTools\Console\Logger\Processor\CommandOutputProcessor;
41use FastForward\DevTools\Console\Logger\Processor\CompositeContextProcessor;
42use FastForward\DevTools\Console\Logger\Processor\ContextProcessorInterface;
43use FastForward\DevTools\Console\Output\GithubActionOutput;
44use FastForward\DevTools\Filesystem\FinderFactory;
45use FastForward\DevTools\Filesystem\FinderFactoryInterface;
46use FastForward\DevTools\Filesystem\Filesystem;
47use FastForward\DevTools\Filesystem\FilesystemInterface;
48use FastForward\DevTools\GitAttributes\CandidateProvider;
49use FastForward\DevTools\GitAttributes\CandidateProviderInterface;
50use FastForward\DevTools\GitAttributes\ExistenceChecker;
51use FastForward\DevTools\GitAttributes\ExistenceCheckerInterface;
52use FastForward\DevTools\GitAttributes\ExportIgnoreFilter;
53use FastForward\DevTools\GitAttributes\ExportIgnoreFilterInterface;
54use FastForward\DevTools\GitAttributes\Merger as GitAttributesMerger;
55use FastForward\DevTools\GitAttributes\MergerInterface as GitAttributesMergerInterface;
56use FastForward\DevTools\GitAttributes\Reader as GitAttributesReader;
57use FastForward\DevTools\GitAttributes\ReaderInterface as GitAttributesReaderInterface;
58use FastForward\DevTools\GitAttributes\Writer as GitAttributesWriter;
59use FastForward\DevTools\GitAttributes\WriterInterface as GitAttributesWriterInterface;
60use FastForward\DevTools\GitIgnore\Merger;
61use FastForward\DevTools\GitIgnore\MergerInterface;
62use FastForward\DevTools\GitIgnore\Reader;
63use FastForward\DevTools\GitIgnore\ReaderInterface;
64use FastForward\DevTools\GitIgnore\Writer;
65use FastForward\DevTools\GitIgnore\WriterInterface;
66use FastForward\DevTools\License\Generator;
67use FastForward\DevTools\License\GeneratorInterface;
68use FastForward\DevTools\License\Resolver;
69use FastForward\DevTools\License\ResolverInterface;
70use FastForward\DevTools\PhpUnit\Coverage\CoverageSummaryLoader;
71use FastForward\DevTools\PhpUnit\Coverage\CoverageSummaryLoaderInterface;
72use FastForward\DevTools\Process\ProcessBuilder;
73use FastForward\DevTools\Process\ProcessBuilderInterface;
74use FastForward\DevTools\Process\ProcessQueue;
75use FastForward\DevTools\Process\ProcessQueueInterface;
76use FastForward\DevTools\Path\DevToolsPathResolver;
77use FastForward\DevTools\Path\WorkingProjectPathResolver;
78use FastForward\DevTools\Psr\Clock\SystemClock;
79use FastForward\DevTools\Resource\DifferInterface;
80use FastForward\DevTools\Resource\UnifiedDiffer;
81use Interop\Container\ServiceProviderInterface;
82use Psr\Clock\ClockInterface;
83use Psr\Log\LoggerInterface;
84use SebastianBergmann\Diff\Output\DiffOutputBuilderInterface;
85use SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder;
86use Symfony\Component\Config\FileLocator;
87use Symfony\Component\Config\FileLocatorInterface;
88use Symfony\Component\Console\CommandLoader\CommandLoaderInterface;
89use Symfony\Component\Console\Output\ConsoleOutput;
90use Symfony\Component\Console\Output\ConsoleOutputInterface;
91use Twig\Loader\FilesystemLoader;
92use Twig\Loader\LoaderInterface;
93
94use function DI\create;
95use function DI\get;
96
97/**
98 * DevToolsServiceProvider registers the services provided by this package.
99 *
100 * This class implements the ServiceProviderInterface from the PHP-Interop container package,
101 * allowing it to be used with any compatible dependency injection container.
102 */
103 class DevToolsServiceProvider implements ServiceProviderInterface
104{
105    /**
106     * @return array
107     */
108    public function getFactories(): array
109    {
110        return [
111            // Process
112            ProcessBuilderInterface::class => get(ProcessBuilder::class),
113            ProcessQueueInterface::class => get(ProcessQueue::class),
114
115            // Filesystem
116            FinderFactoryInterface::class => get(FinderFactory::class),
117            FilesystemInterface::class => get(Filesystem::class),
118
119            // Composer
120            ComposerJsonInterface::class => get(ComposerJson::class),
121
122            // Changelog
123            ChangelogManagerInterface::class => get(ChangelogManager::class),
124            ChangelogParserInterface::class => get(ChangelogParser::class),
125            MarkdownRendererInterface::class => get(MarkdownRenderer::class),
126            UnreleasedEntryCheckerInterface::class => get(UnreleasedEntryChecker::class),
127
128            // Git
129            GitClientInterface::class => get(GitClient::class),
130
131            // Symfony Components
132            FileLocatorInterface::class => create(FileLocator::class)->constructor([
133                WorkingProjectPathResolver::getProjectPath(),
134                DevToolsPathResolver::getPackagePath(),
135            ]),
136
137            // PSR
138            LoggerInterface::class => get(OutputFormatLogger::class),
139            ClockInterface::class => get(SystemClock::class),
140
141            // Console
142            CommandLoaderInterface::class => get(DevToolsCommandLoader::class),
143            CommandProvider::class => get(DevToolsCommandProvider::class),
144            ConsoleOutputInterface::class => create(ConsoleOutput::class)
145                ->method('setVerbosity', ConsoleOutputInterface::VERBOSITY_VERBOSE)
146                ->method('setFormatter', get(LogLevelOutputFormatter::class)),
147            GithubActionOutput::class => create(GithubActionOutput::class)->constructor(
148                get(ConsoleOutputInterface::class)
149            ),
150            ContextProcessorInterface::class => create(CompositeContextProcessor::class)->constructor([
151                get(CommandInputProcessor::class),
152                get(CommandOutputProcessor::class),
153            ]),
154
155            // Coverage
156            CoverageSummaryLoaderInterface::class => get(CoverageSummaryLoader::class),
157
158            // Resource
159            DiffOutputBuilderInterface::class => get(UnifiedDiffOutputBuilder::class),
160            DifferInterface::class => get(UnifiedDiffer::class),
161
162            // GitIgnore
163            MergerInterface::class => get(Merger::class),
164            ReaderInterface::class => get(Reader::class),
165            WriterInterface::class => get(Writer::class),
166
167            // GitAttributes
168            CandidateProviderInterface::class => get(CandidateProvider::class),
169            ExistenceCheckerInterface::class => get(ExistenceChecker::class),
170            ExportIgnoreFilterInterface::class => get(ExportIgnoreFilter::class),
171            GitAttributesMergerInterface::class => get(GitAttributesMerger::class),
172            GitAttributesReaderInterface::class => get(GitAttributesReader::class),
173            GitAttributesWriterInterface::class => get(GitAttributesWriter::class),
174
175            // License
176            GeneratorInterface::class => get(Generator::class),
177            ResolverInterface::class => get(Resolver::class),
178
179            // Twig
180            LoaderInterface::class => create(FilesystemLoader::class)->constructor(
181                DevToolsPathResolver::getResourcesPath()
182            ),
183        ];
184    }
185
186    /**
187     * @return array
188     */
189    public function getExtensions(): array
190    {
191        return [];
192    }
193}