| Total Complexity | 11 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Coverage | 84% |
| Changes | 3 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 10 | final class CommentFactory |
||
| 11 | { |
||
| 12 | /** @var array<array-key, CommentTypeInterface> */ |
||
|
|
|||
| 13 | private array $commentTypes; |
||
| 14 | private array $allowedTypes; |
||
| 15 | |||
| 16 | 13 | public function __construct(array $allowedTypes = []) |
|
| 17 | { |
||
| 18 | 13 | $this->commentTypes = [ |
|
| 19 | 13 | new TodoComment(), |
|
| 20 | 13 | new FixMeComment(), |
|
| 21 | 13 | new RegularComment(), |
|
| 22 | 13 | new LicenseComment(), |
|
| 23 | 13 | new DocBlockComment(), |
|
| 24 | 13 | ]; |
|
| 25 | |||
| 26 | 13 | $this->allowedTypes = $allowedTypes; |
|
| 27 | } |
||
| 28 | |||
| 29 | public function getCommentTypes(): Generator |
||
| 30 | { |
||
| 31 | foreach ($this->commentTypes as $commentType) { |
||
| 32 | yield $commentType; |
||
| 33 | } |
||
| 34 | } |
||
| 35 | |||
| 36 | 2 | public function getCommentType(string $name): ?CommentTypeInterface |
|
| 37 | { |
||
| 38 | 2 | foreach ($this->commentTypes as $commentType) { |
|
| 39 | 2 | if ($commentType->getName() === $name) { |
|
| 40 | 2 | return $commentType; |
|
| 41 | } |
||
| 42 | } |
||
| 43 | 2 | return null; |
|
| 44 | } |
||
| 45 | |||
| 46 | 9 | public function classifyComment(string $token): ?CommentTypeInterface |
|
| 60 | } |
||
| 61 | } |
||
| 62 |