Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 12 |
CRAP | |
0.00% |
0 / 1 |
| ProjectCapabilities | |
0.00% |
0 / 12 |
|
0.00% |
0 / 12 |
240 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getApiDirectories | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getDefaultPackageName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| hasGuideDirectory | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| hasTestsPath | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| hasWikiTarget | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| hasPhpSourceFiles | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| canGenerateApiDocumentation | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| canGenerateDocs | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
| canGenerateMetrics | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| canGenerateWiki | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
| canRunTests | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
| 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\Project; |
| 21 | |
| 22 | /** |
| 23 | * Captures which documentation, testing, and wiki surfaces are available for the current repository. |
| 24 | */ |
| 25 | class ProjectCapabilities |
| 26 | { |
| 27 | /** |
| 28 | * Creates a repository capability snapshot for reporting and documentation commands. |
| 29 | * |
| 30 | * @param list<string> $apiDirectories project-relative directories that contain autoloaded PHP API source |
| 31 | * @param string|null $defaultPackageName the default package name derived from Composer namespaces when available |
| 32 | * @param bool $hasGuideDirectory whether the configured guide directory exists |
| 33 | * @param bool $hasTestsPath whether the configured tests path exists |
| 34 | * @param bool $hasWikiTarget whether the configured wiki target exists |
| 35 | * @param bool $hasPhpSourceFiles whether the repository exposes autoloaded PHP source that can be tested |
| 36 | */ |
| 37 | public function __construct( |
| 38 | private array $apiDirectories, |
| 39 | private ?string $defaultPackageName, |
| 40 | private bool $hasGuideDirectory, |
| 41 | private bool $hasTestsPath, |
| 42 | private bool $hasWikiTarget, |
| 43 | private bool $hasPhpSourceFiles, |
| 44 | ) {} |
| 45 | |
| 46 | /** |
| 47 | * Returns the project-relative directories that expose autoloaded PHP API source. |
| 48 | */ |
| 49 | public function getApiDirectories(): array |
| 50 | { |
| 51 | return $this->apiDirectories; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Returns the default API package name when one can be derived from Composer namespaces. |
| 56 | */ |
| 57 | public function getDefaultPackageName(): ?string |
| 58 | { |
| 59 | return $this->defaultPackageName; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Detects whether the configured guide directory exists. |
| 64 | */ |
| 65 | public function hasGuideDirectory(): bool |
| 66 | { |
| 67 | return $this->hasGuideDirectory; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Detects whether the configured tests directory exists. |
| 72 | */ |
| 73 | public function hasTestsPath(): bool |
| 74 | { |
| 75 | return $this->hasTestsPath; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Detects whether the configured wiki target exists. |
| 80 | */ |
| 81 | public function hasWikiTarget(): bool |
| 82 | { |
| 83 | return $this->hasWikiTarget; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Detects whether the repository exposes autoloaded PHP source that can be tested. |
| 88 | */ |
| 89 | public function hasPhpSourceFiles(): bool |
| 90 | { |
| 91 | return $this->hasPhpSourceFiles; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Detects whether the repository exposes autoloaded PHP API source. |
| 96 | */ |
| 97 | public function canGenerateApiDocumentation(): bool |
| 98 | { |
| 99 | return [] !== $this->apiDirectories; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Detects whether the repository can generate guides, API documentation, or both. |
| 104 | */ |
| 105 | public function canGenerateDocs(): bool |
| 106 | { |
| 107 | return $this->hasGuideDirectory || $this->canGenerateApiDocumentation(); |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Detects whether metrics generation can analyse repository history and package metadata. |
| 112 | */ |
| 113 | public function canGenerateMetrics(): bool |
| 114 | { |
| 115 | return true; |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * Detects whether wiki generation can render API documentation into the configured wiki target. |
| 120 | */ |
| 121 | public function canGenerateWiki(): bool |
| 122 | { |
| 123 | return $this->hasWikiTarget && $this->canGenerateApiDocumentation(); |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * Detects whether the repository has enough PHP surface to justify running tests. |
| 128 | */ |
| 129 | public function canRunTests(): bool |
| 130 | { |
| 131 | return $this->hasTestsPath || $this->hasPhpSourceFiles; |
| 132 | } |
| 133 | } |