GetStatsByDepartment::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
4
namespace App\Src\UseCases\Domain\Context\Queries;
5
6
7
use App\Src\UseCases\Domain\Context\Model\Characteristic;
8
use App\Src\UseCases\Infra\Sql\ReportingCharacteristicSql;
9
10
class GetStatsByDepartment
11
{
12
    private $reportingCharacteristicsRepository;
13
14
    public function __construct(ReportingCharacteristicSql $reportingCharacteristicSql)
15
    {
16
        $this->reportingCharacteristicsRepository = $reportingCharacteristicSql;
17
    }
18
19
    public function execute(int $pageId, string $type = 'follow'):array
20
    {
21
        $stats = $this->reportingCharacteristicsRepository->getStatsByDepartment($pageId, $type);
22
        $farming = $this->reportingCharacteristicsRepository->getCharacteristicsByUserPage($pageId, $type, Characteristic::FARMING_TYPE);
23
        $cropping = $this->reportingCharacteristicsRepository->getCharacteristicsByUserPage($pageId, $type, Characteristic::CROPPING_SYSTEM);
24
        return [
25
            'department' => $stats,
26
            'characteristics' => [
27
                Characteristic::FARMING_TYPE => $farming,
28
                Characteristic::CROPPING_SYSTEM => $cropping
29
            ]
30
        ];
31
    }
32
}
33