Passed
Push — master ( f5fd25...253018 )
by Davis
35s
created

ListTrails::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 6
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 6
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 3
crap 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: davis
5
 * Date: 7/23/17
6
 * Time: 3:12 AM
7
 */
8
9
namespace DavisPeixoto\BlogCore\Service;
10
11
12
use DavisPeixoto\BlogCore\Interfaces\ServiceInterface;
13
use DavisPeixoto\BlogCore\Repository\AbstractTrailRepository;
14
use Psr\Log\LoggerInterface;
15
use Exception;
16
use stdClass;
17
18
/**
19
 * Class ListTrails
20
 * @package DavisPeixoto\BlogCore\Service
21
 */
22 View Code Duplication
class ListTrails implements ServiceInterface
23
{
24
    /**
25
     * @var AbstractTrailRepository
26
     */
27
    private $trailRepository;
28
29
    /**
30
     * @var array
31
     */
32
    private $filters;
33
34
    /**
35
     * @var LoggerInterface
36
     */
37
    private $logger;
38
39
    /**
40
     * ListTrails constructor.
41
     * @param AbstractTrailRepository $trailRepository
42
     * @param array $filters
43
     * @param LoggerInterface $logger
44
     */
45 2
    public function __construct(AbstractTrailRepository $trailRepository, Array $filters, LoggerInterface $logger)
46
    {
47 2
        $this->trailRepository = $trailRepository;
48 2
        $this->filters = $filters;
49 2
        $this->logger = $logger;
50 2
    }
51
52
    /**
53
     * @return array|stdClass[]
54
     */
55 2
    public function run(): array
56
    {
57
        try {
58 2
            return $this->trailRepository->getList($this->filters);
59 1
        } catch (Exception $e) {
60 1
            $this->logger->error($e->getMessage());
61
        }
62
63 1
        return [];
64
    }
65
}
66