Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
64.71% |
11 / 17 |
|
64.71% |
11 / 17 |
|
68.75% |
11 / 16 |
|
84.62% |
11 / 13 |
CRAP | |
0.00% |
0 / 1 |
| MaintainWordCommand | |
64.71% |
11 / 17 |
|
64.71% |
11 / 17 |
|
68.75% |
11 / 16 |
|
84.62% |
11 / 13 |
21.87 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| validate | |
0.00% |
0 / 4 |
|
0.00% |
0 / 5 |
|
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| setWordId | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getWordId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getLabel | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getGender | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getLang | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getOffenseLevel | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getStatus | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isAsSubject | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isAsQualifier | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isHandleDeletion | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getQualifierPosition | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Dto\Command; |
| 4 | |
| 5 | use App\Enum\Lang; |
| 6 | use App\Enum\OffenseLevel; |
| 7 | use App\Enum\QualifierPosition; |
| 8 | use App\Enum\WordGender; |
| 9 | use App\Enum\WordStatus; |
| 10 | use App\Exception\ValidationErrorMessage; |
| 11 | use Symfony\Component\Validator\Constraints as Assert; |
| 12 | use Symfony\Component\Validator\Context\ExecutionContextInterface; |
| 13 | |
| 14 | /** |
| 15 | * @author Wilhelm Zwertvaegher |
| 16 | */ |
| 17 | class MaintainWordCommand |
| 18 | { |
| 19 | public function __construct( |
| 20 | #[Assert\NotBlank(message: ValidationErrorMessage::FIELD_CANNOT_BE_EMPTY)] |
| 21 | #[Assert\Length(min: 2, minMessage: ValidationErrorMessage::FIELD_VALUE_TOO_SHORT)] |
| 22 | private readonly string $label, |
| 23 | private readonly WordGender $gender, |
| 24 | private readonly Lang $lang, |
| 25 | private readonly OffenseLevel $offenseLevel, |
| 26 | private readonly WordStatus $status, |
| 27 | private readonly bool $asSubject = false, |
| 28 | private readonly bool $asQualifier = false, |
| 29 | private readonly ?QualifierPosition $qualifierPosition = null, |
| 30 | private ?int $wordId = null, |
| 31 | private readonly bool $handleDeletion = true, |
| 32 | ) { |
| 33 | } |
| 34 | |
| 35 | #[Assert\Callback] |
| 36 | public function validate(ExecutionContextInterface $context, mixed $payload): void |
| 37 | { |
| 38 | if ($this->asQualifier && empty($this->qualifierPosition)) { |
| 39 | $context->buildViolation(ValidationErrorMessage::QUALIFIER_POSITION_CANNOT_BE_EMPTY) |
| 40 | ->atPath('qualifierPosition') |
| 41 | ->addViolation(); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | public function setWordId(int $wordId): self |
| 46 | { |
| 47 | $this->wordId = $wordId; |
| 48 | |
| 49 | return $this; |
| 50 | } |
| 51 | |
| 52 | public function getWordId(): ?int |
| 53 | { |
| 54 | return $this->wordId; |
| 55 | } |
| 56 | |
| 57 | public function getLabel(): string |
| 58 | { |
| 59 | return $this->label; |
| 60 | } |
| 61 | |
| 62 | public function getGender(): WordGender |
| 63 | { |
| 64 | return $this->gender; |
| 65 | } |
| 66 | |
| 67 | public function getLang(): Lang |
| 68 | { |
| 69 | return $this->lang; |
| 70 | } |
| 71 | |
| 72 | public function getOffenseLevel(): OffenseLevel |
| 73 | { |
| 74 | return $this->offenseLevel; |
| 75 | } |
| 76 | |
| 77 | public function getStatus(): WordStatus |
| 78 | { |
| 79 | return $this->status; |
| 80 | } |
| 81 | |
| 82 | public function isAsSubject(): bool |
| 83 | { |
| 84 | return $this->asSubject; |
| 85 | } |
| 86 | |
| 87 | public function isAsQualifier(): bool |
| 88 | { |
| 89 | return $this->asQualifier; |
| 90 | } |
| 91 | |
| 92 | public function isHandleDeletion(): bool |
| 93 | { |
| 94 | return $this->handleDeletion; |
| 95 | } |
| 96 | |
| 97 | public function getQualifierPosition(): ?QualifierPosition |
| 98 | { |
| 99 | return $this->qualifierPosition; |
| 100 | } |
| 101 | } |
Below are the source code lines that represent each code branch as identified by Xdebug. Please note a branch is not
necessarily coterminous with a line, a line may contain multiple branches and therefore show up more than once.
Please also be aware that some branches may be implicit rather than explicit, e.g. an if statement
always has an else as part of its logical flow even if you didn't write one.
| 19 | public function __construct( |
| 20 | #[Assert\NotBlank(message: ValidationErrorMessage::FIELD_CANNOT_BE_EMPTY)] |
| 21 | #[Assert\Length(min: 2, minMessage: ValidationErrorMessage::FIELD_VALUE_TOO_SHORT)] |
| 22 | private readonly string $label, |
| 23 | private readonly WordGender $gender, |
| 24 | private readonly Lang $lang, |
| 25 | private readonly OffenseLevel $offenseLevel, |
| 26 | private readonly WordStatus $status, |
| 27 | private readonly bool $asSubject = false, |
| 28 | private readonly bool $asQualifier = false, |
| 29 | private readonly ?QualifierPosition $qualifierPosition = null, |
| 30 | private ?int $wordId = null, |
| 31 | private readonly bool $handleDeletion = true, |
| 32 | ) { |
| 33 | } |
| 64 | return $this->gender; |
| 65 | } |
| 59 | return $this->label; |
| 60 | } |
| 69 | return $this->lang; |
| 70 | } |
| 74 | return $this->offenseLevel; |
| 75 | } |
| 99 | return $this->qualifierPosition; |
| 100 | } |
| 79 | return $this->status; |
| 80 | } |
| 54 | return $this->wordId; |
| 55 | } |
| 89 | return $this->asQualifier; |
| 90 | } |
| 84 | return $this->asSubject; |
| 85 | } |
| 94 | return $this->handleDeletion; |
| 95 | } |
| 45 | public function setWordId(int $wordId): self |
| 46 | { |
| 47 | $this->wordId = $wordId; |
| 48 | |
| 49 | return $this; |
| 50 | } |
| 36 | public function validate(ExecutionContextInterface $context, mixed $payload): void |
| 37 | { |
| 38 | if ($this->asQualifier && empty($this->qualifierPosition)) { |
| 38 | if ($this->asQualifier && empty($this->qualifierPosition)) { |
| 38 | if ($this->asQualifier && empty($this->qualifierPosition)) { |
| 39 | $context->buildViolation(ValidationErrorMessage::QUALIFIER_POSITION_CANNOT_BE_EMPTY) |
| 40 | ->atPath('qualifierPosition') |
| 41 | ->addViolation(); |
| 42 | } |
| 43 | } |
| 43 | } |
| 3 | namespace App\Dto\Command; |
| 4 | |
| 5 | use App\Enum\Lang; |
| 6 | use App\Enum\OffenseLevel; |
| 7 | use App\Enum\QualifierPosition; |
| 8 | use App\Enum\WordGender; |
| 9 | use App\Enum\WordStatus; |
| 10 | use App\Exception\ValidationErrorMessage; |
| 11 | use Symfony\Component\Validator\Constraints as Assert; |
| 12 | use Symfony\Component\Validator\Context\ExecutionContextInterface; |
| 13 | |
| 14 | /** |
| 15 | * @author Wilhelm Zwertvaegher |
| 16 | */ |
| 17 | class MaintainWordCommand |
| 18 | { |
| 19 | public function __construct( |
| 20 | #[Assert\NotBlank(message: ValidationErrorMessage::FIELD_CANNOT_BE_EMPTY)] |
| 21 | #[Assert\Length(min: 2, minMessage: ValidationErrorMessage::FIELD_VALUE_TOO_SHORT)] |
| 22 | private readonly string $label, |
| 23 | private readonly WordGender $gender, |
| 24 | private readonly Lang $lang, |
| 25 | private readonly OffenseLevel $offenseLevel, |
| 26 | private readonly WordStatus $status, |
| 27 | private readonly bool $asSubject = false, |
| 28 | private readonly bool $asQualifier = false, |
| 29 | private readonly ?QualifierPosition $qualifierPosition = null, |
| 30 | private ?int $wordId = null, |
| 31 | private readonly bool $handleDeletion = true, |
| 32 | ) { |
| 33 | } |
| 34 | |
| 35 | #[Assert\Callback] |
| 36 | public function validate(ExecutionContextInterface $context, mixed $payload): void |
| 37 | { |
| 38 | if ($this->asQualifier && empty($this->qualifierPosition)) { |
| 39 | $context->buildViolation(ValidationErrorMessage::QUALIFIER_POSITION_CANNOT_BE_EMPTY) |
| 40 | ->atPath('qualifierPosition') |
| 41 | ->addViolation(); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | public function setWordId(int $wordId): self |
| 46 | { |
| 47 | $this->wordId = $wordId; |
| 48 | |
| 49 | return $this; |
| 50 | } |
| 51 | |
| 52 | public function getWordId(): ?int |
| 53 | { |
| 54 | return $this->wordId; |
| 55 | } |
| 56 | |
| 57 | public function getLabel(): string |
| 58 | { |
| 59 | return $this->label; |
| 60 | } |
| 61 | |
| 62 | public function getGender(): WordGender |
| 63 | { |
| 64 | return $this->gender; |
| 65 | } |
| 66 | |
| 67 | public function getLang(): Lang |
| 68 | { |
| 69 | return $this->lang; |
| 70 | } |
| 71 | |
| 72 | public function getOffenseLevel(): OffenseLevel |
| 73 | { |
| 74 | return $this->offenseLevel; |
| 75 | } |
| 76 | |
| 77 | public function getStatus(): WordStatus |
| 78 | { |
| 79 | return $this->status; |
| 80 | } |
| 81 | |
| 82 | public function isAsSubject(): bool |
| 83 | { |
| 84 | return $this->asSubject; |
| 85 | } |
| 86 | |
| 87 | public function isAsQualifier(): bool |
| 88 | { |
| 89 | return $this->asQualifier; |
| 90 | } |
| 91 | |
| 92 | public function isHandleDeletion(): bool |
| 93 | { |
| 94 | return $this->handleDeletion; |
| 95 | } |
| 96 | |
| 97 | public function getQualifierPosition(): ?QualifierPosition |
| 98 | { |
| 99 | return $this->qualifierPosition; |
| 100 | } |