Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
12 / 12 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
| ApieModifyResourceCommand | |
100.00% |
12 / 12 |
|
100.00% |
5 / 5 |
5 | |
100.00% |
1 / 1 |
| getCommandName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getCommandHelp | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getMetadata | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| getSuccessMessage | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| requiresId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace Apie\Console\Commands; |
| 3 | |
| 4 | use Apie\Core\Actions\ActionResponse; |
| 5 | use Apie\Core\Identifiers\KebabCaseSlug; |
| 6 | use Apie\Core\Metadata\MetadataFactory; |
| 7 | use Apie\Core\Metadata\MetadataInterface; |
| 8 | use ReflectionClass; |
| 9 | |
| 10 | final class ApieModifyResourceCommand extends ApieMetadataDirectedConsoleCommand |
| 11 | { |
| 12 | protected function getCommandName(): string |
| 13 | { |
| 14 | return KebabCaseSlug::fromClass($this->reflectionClass) . ':modify'; |
| 15 | } |
| 16 | |
| 17 | protected function getCommandHelp(): string |
| 18 | { |
| 19 | return 'This command allows you to modify a ' . $this->reflectionClass->getShortName() . ' instance'; |
| 20 | } |
| 21 | |
| 22 | protected function getMetadata(): MetadataInterface |
| 23 | { |
| 24 | return MetadataFactory::getModificationMetadata( |
| 25 | $this->reflectionClass, |
| 26 | $this->apieContext |
| 27 | ); |
| 28 | } |
| 29 | |
| 30 | protected function getSuccessMessage(ActionResponse $actionResponse): string |
| 31 | { |
| 32 | return sprintf( |
| 33 | "Resource %s with id %s was successfully modified.", |
| 34 | (new ReflectionClass($actionResponse->resource))->getShortName(), |
| 35 | $actionResponse->resource->getId(), |
| 36 | ); |
| 37 | } |
| 38 | |
| 39 | protected function requiresId(): bool |
| 40 | { |
| 41 | return true; |
| 42 | } |
| 43 | } |