| Total Complexity | 8 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Coverage | 93.33% |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class Answer implements AnswerInterface |
||
| 8 | { |
||
| 9 | private string $sourceString; |
||
| 10 | private array $correctedStringArray = []; |
||
| 11 | |||
| 12 | // @ToDo: add the ability to set the language for error correction |
||
| 13 | 7 | public function __construct(string $string, array $correctedStringArray) |
|
| 14 | { |
||
| 15 | 7 | $this->sourceString = trim($string); |
|
| 16 | |||
| 17 | 7 | foreach ($correctedStringArray as $correctedString) { |
|
| 18 | 5 | if (empty(trim($correctedString))) { |
|
| 19 | continue; |
||
| 20 | } |
||
| 21 | |||
| 22 | 5 | $this->correctedStringArray[] = $correctedString; |
|
| 23 | } |
||
| 24 | 7 | } |
|
| 25 | |||
| 26 | 1 | public function getSourceString(): string |
|
| 29 | } |
||
| 30 | |||
| 31 | 2 | public function getFirstCorrectedString(): string |
|
| 32 | { |
||
| 33 | 2 | return (empty($this->isStringCorrected())) ? '' : reset($this->correctedStringArray); |
|
| 34 | } |
||
| 35 | |||
| 36 | 1 | public function getCorrectedArray(): array |
|
| 39 | } |
||
| 40 | |||
| 41 | 4 | public function isStringCorrected(): bool |
|
| 44 | } |
||
| 45 | } |
||
| 46 |