Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
14 / 14 |
MainController | |
100.00% |
1 / 1 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
14 / 14 |
__construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
3 / 3 |
|||
index | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
image | |
100.00% |
1 / 1 |
1 | |
100.00% |
9 / 9 |
<?php | |
declare(strict_types=1); | |
namespace App\Controller; | |
use App\Request\ImageRequest; | |
use App\Service\PlaceholderGenerator; | |
use App\Service\ResolutionService; | |
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | |
use Symfony\Component\HttpFoundation\JsonResponse; | |
use Symfony\Component\HttpFoundation\Request; | |
use Symfony\Component\HttpFoundation\Response; | |
class MainController extends AbstractController | |
{ | |
/** | |
* @var PlaceholderGenerator | |
*/ | |
private $placeholderGenerator; | |
/** | |
* @var ResolutionService | |
*/ | |
private $resolutionService; | |
public function __construct( | |
PlaceholderGenerator $placeholderGenerator, | |
ResolutionService $resolutionService | |
) { | |
$this->placeholderGenerator = $placeholderGenerator; | |
$this->resolutionService = $resolutionService; | |
} | |
public function index(Request $request): Response | |
{ | |
return new JsonResponse([ | |
'status' => 'ok', | |
'service' => 'placeholder service', | |
]); | |
} | |
public function image(Request $request): Response | |
{ | |
$imageRequest = ImageRequest::create($request); | |
$resolution = $this->resolutionService->createFromRequest($imageRequest); | |
return $this->placeholderGenerator->generate( | |
$resolution->getWidth(), | |
$resolution->getHeight(), | |
$imageRequest->getText(), | |
$imageRequest->getTextSize(), | |
$imageRequest->getColorText(), | |
$imageRequest->getColorBg() | |
); | |
} | |
} |