Completed
Push — master ( b738e4...21fbcf )
by Davis
01:22
created

GetAuthor::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 5
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 3
dl 5
loc 5
rs 9.4285
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\AuthorRepository;
14
use Psr\Log\LoggerInterface;
15
use Exception;
16
use Ramsey\Uuid\UuidInterface;
17
use stdClass;
18
19
/**
20
 * Class GetAuthor
21
 * @package DavisPeixoto\BlogCore\Service
22
 */
23 View Code Duplication
class GetAuthor implements ServiceInterface
24
{
25
    /**
26
     * @var AuthorRepository
27
     */
28
    private $authorRepository;
29
30
    /**
31
     * @var UuidInterface
32
     */
33
    private $uuid;
34
35
    /**
36
     * @var LoggerInterface
37
     */
38
    private $logger;
39
40
    /**
41
     * GetAuthor constructor.
42
     * @param AuthorRepository $authorRepository
43
     * @param UuidInterface $uuid
44
     * @param LoggerInterface $logger
45
     */
46
    public function __construct(AuthorRepository $authorRepository, UuidInterface $uuid, LoggerInterface $logger)
47
    {
48
        $this->authorRepository = $authorRepository;
49
        $this->uuid = $uuid;
50
        $this->logger = $logger;
51
    }
52
53
    /**
54
     * @return stdClass|boolean
55
     */
56
    public function run()
57
    {
58
        try {
59
            return $this->authorRepository->get($this->uuid);
60
        } catch (Exception $e) {
61
            $this->logger->error($e->getMessage());
62
        }
63
64
        return false;
65
    }
66
}
67