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

src/BlogCore/Service/CreateTag.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\Entity\Tag;
13
use DavisPeixoto\BlogCore\Interfaces\ServiceInterface;
14
use DavisPeixoto\BlogCore\Repository\AbstractTagRepository;
15
use Exception;
16
use Psr\Log\LoggerInterface;
17
use Ramsey\Uuid\UuidInterface;
18
19
/**
20
 * Class CreateTag
21
 * @package DavisPeixoto\BlogCore\Service
22
 */
23 View Code Duplication
class CreateTag implements ServiceInterface
24
{
25
    /**
26
     * @var AbstractTagRepository
27
     */
28
    private $tagRepository;
29
30
    /**
31
     * @var Tag
32
     */
33
    private $tag;
34
35
    /**
36
     * @var LoggerInterface
37
     */
38
    private $logger;
39
40
    /**
41
     * CreateTag constructor.
42
     * @param AbstractTagRepository $tagRepository
43
     * @param Tag $tag
44
     * @param LoggerInterface $logger
45
     */
46 2
    public function __construct(AbstractTagRepository $tagRepository, Tag $tag, LoggerInterface $logger)
47
    {
48 2
        $this->tagRepository = $tagRepository;
49 2
        $this->tag = $tag;
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->tagRepository->save($this->tag);
60 1
        } catch (Exception $e) {
61 1
            $this->logger->error($e->getMessage());
62
        }
63
64 1
        return null;
65
    }
66
}
67