Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
48 / 48 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| DevToolsServiceProvider | |
100.00% |
48 / 48 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| getFactories | |
100.00% |
47 / 47 |
|
100.00% |
1 / 1 |
1 | |||
| getExtensions | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(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 | |
| 20 | namespace FastForward\DevTools\ServiceProvider; |
| 21 | |
| 22 | use Composer\Plugin\Capability\CommandProvider; |
| 23 | use FastForward\DevTools\Changelog\Manager\ChangelogManager; |
| 24 | use FastForward\DevTools\Changelog\Manager\ChangelogManagerInterface; |
| 25 | use FastForward\DevTools\Changelog\Parser\ChangelogParser; |
| 26 | use FastForward\DevTools\Changelog\Parser\ChangelogParserInterface; |
| 27 | use FastForward\DevTools\Composer\Capability\DevToolsCommandProvider; |
| 28 | use FastForward\DevTools\Composer\Json\ComposerJson; |
| 29 | use FastForward\DevTools\Composer\Json\ComposerJsonInterface; |
| 30 | use FastForward\DevTools\Git\GitClient; |
| 31 | use FastForward\DevTools\Git\GitClientInterface; |
| 32 | use FastForward\DevTools\Changelog\Renderer\MarkdownRenderer; |
| 33 | use FastForward\DevTools\Changelog\Renderer\MarkdownRendererInterface; |
| 34 | use FastForward\DevTools\Changelog\Checker\UnreleasedEntryChecker; |
| 35 | use FastForward\DevTools\Changelog\Checker\UnreleasedEntryCheckerInterface; |
| 36 | use FastForward\DevTools\Console\CommandLoader\DevToolsCommandLoader; |
| 37 | use FastForward\DevTools\Console\Formatter\LogLevelOutputFormatter; |
| 38 | use FastForward\DevTools\Console\Logger\OutputFormatLogger; |
| 39 | use FastForward\DevTools\Console\Logger\Processor\CommandInputProcessor; |
| 40 | use FastForward\DevTools\Console\Logger\Processor\CommandOutputProcessor; |
| 41 | use FastForward\DevTools\Console\Logger\Processor\CompositeContextProcessor; |
| 42 | use FastForward\DevTools\Console\Logger\Processor\ContextProcessorInterface; |
| 43 | use FastForward\DevTools\Console\Output\GithubActionOutput; |
| 44 | use FastForward\DevTools\Filesystem\FinderFactory; |
| 45 | use FastForward\DevTools\Filesystem\FinderFactoryInterface; |
| 46 | use FastForward\DevTools\Filesystem\Filesystem; |
| 47 | use FastForward\DevTools\Filesystem\FilesystemInterface; |
| 48 | use FastForward\DevTools\GitAttributes\CandidateProvider; |
| 49 | use FastForward\DevTools\GitAttributes\CandidateProviderInterface; |
| 50 | use FastForward\DevTools\GitAttributes\ExistenceChecker; |
| 51 | use FastForward\DevTools\GitAttributes\ExistenceCheckerInterface; |
| 52 | use FastForward\DevTools\GitAttributes\ExportIgnoreFilter; |
| 53 | use FastForward\DevTools\GitAttributes\ExportIgnoreFilterInterface; |
| 54 | use FastForward\DevTools\GitAttributes\Merger as GitAttributesMerger; |
| 55 | use FastForward\DevTools\GitAttributes\MergerInterface as GitAttributesMergerInterface; |
| 56 | use FastForward\DevTools\GitAttributes\Reader as GitAttributesReader; |
| 57 | use FastForward\DevTools\GitAttributes\ReaderInterface as GitAttributesReaderInterface; |
| 58 | use FastForward\DevTools\GitAttributes\Writer as GitAttributesWriter; |
| 59 | use FastForward\DevTools\GitAttributes\WriterInterface as GitAttributesWriterInterface; |
| 60 | use FastForward\DevTools\GitIgnore\Merger; |
| 61 | use FastForward\DevTools\GitIgnore\MergerInterface; |
| 62 | use FastForward\DevTools\GitIgnore\Reader; |
| 63 | use FastForward\DevTools\GitIgnore\ReaderInterface; |
| 64 | use FastForward\DevTools\GitIgnore\Writer; |
| 65 | use FastForward\DevTools\GitIgnore\WriterInterface; |
| 66 | use FastForward\DevTools\License\Generator; |
| 67 | use FastForward\DevTools\License\GeneratorInterface; |
| 68 | use FastForward\DevTools\License\Resolver; |
| 69 | use FastForward\DevTools\License\ResolverInterface; |
| 70 | use FastForward\DevTools\PhpUnit\Coverage\CoverageSummaryLoader; |
| 71 | use FastForward\DevTools\PhpUnit\Coverage\CoverageSummaryLoaderInterface; |
| 72 | use FastForward\DevTools\Process\ProcessBuilder; |
| 73 | use FastForward\DevTools\Process\ProcessBuilderInterface; |
| 74 | use FastForward\DevTools\Process\ProcessQueue; |
| 75 | use FastForward\DevTools\Process\ProcessQueueInterface; |
| 76 | use FastForward\DevTools\Path\DevToolsPathResolver; |
| 77 | use FastForward\DevTools\Path\WorkingProjectPathResolver; |
| 78 | use FastForward\DevTools\Psr\Clock\SystemClock; |
| 79 | use FastForward\DevTools\Resource\DifferInterface; |
| 80 | use FastForward\DevTools\Resource\UnifiedDiffer; |
| 81 | use Interop\Container\ServiceProviderInterface; |
| 82 | use Psr\Clock\ClockInterface; |
| 83 | use Psr\Log\LoggerInterface; |
| 84 | use SebastianBergmann\Diff\Output\DiffOutputBuilderInterface; |
| 85 | use SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder; |
| 86 | use Symfony\Component\Config\FileLocator; |
| 87 | use Symfony\Component\Config\FileLocatorInterface; |
| 88 | use Symfony\Component\Console\CommandLoader\CommandLoaderInterface; |
| 89 | use Symfony\Component\Console\Output\ConsoleOutput; |
| 90 | use Symfony\Component\Console\Output\ConsoleOutputInterface; |
| 91 | use Twig\Loader\FilesystemLoader; |
| 92 | use Twig\Loader\LoaderInterface; |
| 93 | |
| 94 | use function DI\create; |
| 95 | use 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 | } |