GetStatsByDepartment   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 19
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A execute() 0 10 1
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