Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
11 / 11 |
ShoutPresenterWrapper | |
100.00% |
1 / 1 |
|
100.00% |
4 / 4 |
4 | |
100.00% |
11 / 11 |
__construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
getAuthor | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
getQuote | |
100.00% |
1 / 1 |
1 | |
100.00% |
6 / 6 |
|||
toArray | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
<?php | |
declare(strict_types=1); | |
namespace App\Quote\Presenter; | |
use App\Quote\Model\QuoteInterface; | |
use Symfony\Component\String\ByteString; | |
final class ShoutPresenterWrapper implements ShoutPresenterWrapperInterface | |
{ | |
private QuoteInterface $quote; | |
public function __construct(QuoteInterface $quote) | |
{ | |
$this->quote = $quote; | |
} | |
public function getAuthor(): string | |
{ | |
return (new ByteString($this->quote->getAuthor()))->trim()->replace('-', ' ')->title(true)->toString(); | |
} | |
public function getQuote(): string | |
{ | |
return (new ByteString($this->quote->getQuote())) | |
->trim() | |
->upper() | |
->trimEnd('.') | |
->ensureEnd('!') | |
->toString(); | |
} | |
public function toArray(): array | |
{ | |
return [ | |
'author' => $this->getAuthor(), | |
'quote' => $this->getQuote() | |
]; | |
} | |
} |