| Code Coverage | ||||||||||
| Lines | Functions and Methods | Classes and Traits | ||||||||
| Total |  | 100.00% | 12 / 12 |  | 100.00% | 5 / 5 | CRAP |  | 100.00% | 1 / 1 | 
| ApieRunResourceMethodCommand |  | 100.00% | 12 / 12 |  | 100.00% | 5 / 5 | 5 |  | 100.00% | 1 / 1 | 
| getCommandName |  | 100.00% | 2 / 2 |  | 100.00% | 1 / 1 | 1 | |||
| getCommandHelp |  | 100.00% | 2 / 2 |  | 100.00% | 1 / 1 | 1 | |||
| getMetadata |  | 100.00% | 5 / 5 |  | 100.00% | 1 / 1 | 1 | |||
| getSuccessMessage |  | 100.00% | 1 / 1 |  | 100.00% | 1 / 1 | 1 | |||
| requiresId |  | 100.00% | 2 / 2 |  | 100.00% | 1 / 1 | 1 | |||
| 1 | <?php | 
| 2 | namespace Apie\Console\Commands; | 
| 3 | |
| 4 | use Apie\Console\Helpers\DisplayResultHelper; | 
| 5 | use Apie\Core\Actions\ActionResponse; | 
| 6 | use Apie\Core\Identifiers\KebabCaseSlug; | 
| 7 | use Apie\Core\Metadata\MetadataFactory; | 
| 8 | use Apie\Core\Metadata\MetadataInterface; | 
| 9 | |
| 10 | final class ApieRunResourceMethodCommand extends ApieMetadataDirectedConsoleCommand | 
| 11 | { | 
| 12 | protected function getCommandName(): string | 
| 13 | { | 
| 14 | assert(null !== $this->reflectionMethod); | 
| 15 | return KebabCaseSlug::fromClass($this->reflectionClass) . ':run:' . KebabCaseSlug::fromClass($this->reflectionMethod); | 
| 16 | } | 
| 17 | |
| 18 | protected function getCommandHelp(): string | 
| 19 | { | 
| 20 | assert(null !== $this->reflectionMethod); | 
| 21 | return 'This command runs ' . $this->reflectionMethod->getName() . ' from a ' . $this->reflectionClass->getShortName() . ' instance'; | 
| 22 | } | 
| 23 | |
| 24 | protected function getMetadata(): MetadataInterface | 
| 25 | { | 
| 26 | assert(null !== $this->reflectionMethod); | 
| 27 | return MetadataFactory::getMethodMetadata( | 
| 28 | $this->reflectionMethod, | 
| 29 | $this->apieContext | 
| 30 | ); | 
| 31 | } | 
| 32 | |
| 33 | protected function getSuccessMessage(ActionResponse $actionResponse): string | 
| 34 | { | 
| 35 | return 'The result was: ' . PHP_EOL . DisplayResultHelper::displayResult($actionResponse->result); | 
| 36 | } | 
| 37 | |
| 38 | protected function requiresId(): bool | 
| 39 | { | 
| 40 | assert(null !== $this->reflectionMethod); | 
| 41 | return !$this->reflectionMethod->isStatic(); | 
| 42 | } | 
| 43 | } |