Passed
Push — master ( 253018...166e4e )
by Davis
38s
created

src/BlogCore/Service/EditAuthor.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: davis
5
 * Date: 7/23/17
6
 * Time: 3:06 AM
7
 */
8
9
namespace DavisPeixoto\BlogCore\Service;
10
11
12
use DavisPeixoto\BlogCore\Interfaces\ServiceInterface;
13
use DavisPeixoto\BlogCore\Repository\AbstractAuthorRepository;
14
use DavisPeixoto\BlogCore\Entity\Author;
15
use Exception;
16
use Psr\Log\LoggerInterface;
17
use Ramsey\Uuid\UuidInterface;
18
19
/**
20
 * Class EditAuthor
21
 * @package DavisPeixoto\BlogCore\Service
22
 */
23 View Code Duplication
class EditAuthor implements ServiceInterface
24
{
25
    /**
26
     * @var AbstractAuthorRepository
27
     */
28
    private $authorRepository;
29
30
    /**
31
     * @var Author
32
     */
33
    private $author;
34
35
    /**
36
     * @var LoggerInterface
37
     */
38
    private $logger;
39
40
    /**
41
     * EditAuthor constructor.
42
     * @param AbstractAuthorRepository $authorRepository
43
     * @param Author $author
44
     * @param LoggerInterface $logger
45
     */
46 2
    public function __construct(AbstractAuthorRepository $authorRepository, Author $author, LoggerInterface $logger)
47
    {
48 2
        $this->authorRepository = $authorRepository;
49 2
        $this->author = $author;
50 2
        $this->logger = $logger;
51 2
    }
52
53
    /**
54
     * @return UuidInterface|null
0 ignored issues
show
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
55
     */
56 2
    public function run()
57
    {
58
        try {
59 2
            return $this->authorRepository->save($this->author);
60 1
        } catch (Exception $e) {
61 1
            $this->logger->error($e->getMessage());
62
        }
63
64 1
        return null;
65
    }
66
}
67