Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
16.67% |
1 / 6 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Planillas | |
16.67% |
1 / 6 |
|
50.00% |
1 / 2 |
4.31 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| __invoke | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Controller\Download; |
| 6 | |
| 7 | use App\Controller\BaseController; |
| 8 | use App\Service\PayrollHelper; |
| 9 | use App\Service\PdfHelper; |
| 10 | use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse; |
| 11 | use Symfony\Component\Clock\ClockInterface; |
| 12 | use Symfony\Component\Routing\Attribute\Route; |
| 13 | use Symfony\Component\Security\Http\Attribute\IsGranted; |
| 14 | |
| 15 | #[IsGranted('ROLE_ADMIN')] |
| 16 | #[Route(path: '/download/planillas', name: 'download_planillas', methods: ['GET'])] |
| 17 | class Planillas extends BaseController |
| 18 | { |
| 19 | public function __construct( |
| 20 | private readonly PdfHelper $pdfHelper, |
| 21 | private readonly PayrollHelper $payrollHelper, |
| 22 | private readonly ClockInterface $clock, |
| 23 | ) {} |
| 24 | |
| 25 | public function __invoke(): PdfResponse |
| 26 | { |
| 27 | $now = $this->clock->now(); |
| 28 | $year = (int) $now->format('Y'); |
| 29 | $month = (int) $now->format('m'); |
| 30 | $filename = sprintf('payrolls-%d-%d.pdf', $year, $month); |
| 31 | |
| 32 | return new PdfResponse($this->pdfHelper->renderPayrollPdf($year, $month, $this->payrollHelper), $filename); |
| 33 | } |
| 34 | } |