Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
8 / 8 |
|
100.00% |
8 / 8 |
CRAP | |
100.00% |
1 / 1 |
| SynchronizeResult | |
100.00% |
8 / 8 |
|
100.00% |
8 / 8 |
8 | |
100.00% |
1 / 1 |
| addCreatedLink | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| addPreservedLink | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| addRemovedBrokenLink | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| markFailed | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getCreatedLinks | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getPreservedLinks | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getRemovedBrokenLinks | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| failed | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** |
| 6 | * This file is part of fast-forward/dev-tools. |
| 7 | * |
| 8 | * This source file is subject to the license bundled |
| 9 | * with this source code in the file LICENSE. |
| 10 | * |
| 11 | * @copyright Copyright (c) 2026 Felipe Sayão Lobato Abreu <github@mentordosnerds.com> |
| 12 | * @license https://opensource.org/licenses/MIT MIT License |
| 13 | * |
| 14 | * @see https://github.com/php-fast-forward/dev-tools |
| 15 | * @see https://github.com/php-fast-forward |
| 16 | * @see https://datatracker.ietf.org/doc/html/rfc2119 |
| 17 | */ |
| 18 | |
| 19 | namespace FastForward\DevTools\Agent\Skills; |
| 20 | |
| 21 | /** |
| 22 | * Result object for skill synchronization operations. |
| 23 | * |
| 24 | * Tracks the outcomes of a synchronization run, including newly created links, |
| 25 | * existing items that were preserved, and broken links that were removed. |
| 26 | * The failed flag indicates whether an error occurred during synchronization. |
| 27 | */ |
| 28 | class SynchronizeResult |
| 29 | { |
| 30 | /** |
| 31 | * List of skill names for which new symlinks were created. |
| 32 | * |
| 33 | * @var list<string> |
| 34 | */ |
| 35 | private array $createdLinks = []; |
| 36 | |
| 37 | /** |
| 38 | * List of skill names for which existing items were left unchanged. |
| 39 | * |
| 40 | * @var list<string> |
| 41 | */ |
| 42 | private array $preservedLinks = []; |
| 43 | |
| 44 | /** |
| 45 | * List of skill names whose broken symlinks were removed during sync. |
| 46 | * |
| 47 | * @var list<string> |
| 48 | */ |
| 49 | private array $removedBrokenLinks = []; |
| 50 | |
| 51 | /** |
| 52 | * Indicates whether the synchronization encountered a failure. |
| 53 | */ |
| 54 | private bool $failed = false; |
| 55 | |
| 56 | /** |
| 57 | * Records a skill for which a new symlink was created. |
| 58 | * |
| 59 | * @param string $link Name of the skill that received a new symlink |
| 60 | */ |
| 61 | public function addCreatedLink(string $link): void |
| 62 | { |
| 63 | $this->createdLinks[] = $link; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Records a skill whose existing item was preserved unchanged. |
| 68 | * |
| 69 | * @param string $link Name of the skill that was left in place |
| 70 | */ |
| 71 | public function addPreservedLink(string $link): void |
| 72 | { |
| 73 | $this->preservedLinks[] = $link; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Records a skill whose broken symlink was removed during sync. |
| 78 | * |
| 79 | * @param string $link Name of the skill whose broken link was removed |
| 80 | */ |
| 81 | public function addRemovedBrokenLink(string $link): void |
| 82 | { |
| 83 | $this->removedBrokenLinks[] = $link; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Marks the synchronization as failed due to an error condition. |
| 88 | */ |
| 89 | public function markFailed(): void |
| 90 | { |
| 91 | $this->failed = true; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Returns the list of skills for which new symlinks were created. |
| 96 | * |
| 97 | * @return list<string> Skill names of newly created links |
| 98 | */ |
| 99 | public function getCreatedLinks(): array |
| 100 | { |
| 101 | return $this->createdLinks; |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Returns the list of skills whose existing items were preserved. |
| 106 | * |
| 107 | * @return list<string> Skill names of preserved items |
| 108 | */ |
| 109 | public function getPreservedLinks(): array |
| 110 | { |
| 111 | return $this->preservedLinks; |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Returns the list of skills whose broken symlinks were removed. |
| 116 | * |
| 117 | * @return list<string> Skill names of removed broken links |
| 118 | */ |
| 119 | public function getRemovedBrokenLinks(): array |
| 120 | { |
| 121 | return $this->removedBrokenLinks; |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Indicates whether the synchronization encountered a failure. |
| 126 | * |
| 127 | * @return bool True if an error occurred, false otherwise |
| 128 | */ |
| 129 | public function failed(): bool |
| 130 | { |
| 131 | return $this->failed; |
| 132 | } |
| 133 | } |