Code Duplication    Length = 44-44 lines in 2 locations

src/BlogCore/Service/AbstractGetService.php 1 location

@@ 21-64 (lines=44) @@
18
 * Class AbstractGetService
19
 * @package DavisPeixoto\BlogCore\Service
20
 */
21
abstract class AbstractGetService implements ServiceInterface
22
{
23
    /**
24
     * @var RepositoryInterface $repository
25
     */
26
    protected $repository;
27
28
    /**
29
     * @var string $uuid
30
     */
31
    protected $uuid;
32
33
    /**
34
     * @var LoggerInterface $logger
35
     */
36
    protected $logger;
37
38
    /**
39
     * AbstractGetService constructor.
40
     * @param RepositoryInterface $repository
41
     * @param string $uuid
42
     * @param LoggerInterface $logger
43
     */
44
    public function __construct(RepositoryInterface $repository, string $uuid, LoggerInterface $logger)
45
    {
46
        $this->repository = $repository;
47
        $this->uuid = $uuid;
48
        $this->logger = $logger;
49
    }
50
51
    /**
52
     * @return stdClass|null
53
     */
54
    public function run()
55
    {
56
        try {
57
            return $this->repository->get($this->uuid);
58
        } catch (Exception $e) {
59
            $this->logger->error($e->getMessage());
60
        }
61
62
        return null;
63
    }
64
}
65

src/BlogCore/Service/AbstractListService.php 1 location

@@ 21-64 (lines=44) @@
18
 * Class AbstractListService
19
 * @package DavisPeixoto\BlogCore\Service
20
 */
21
abstract class AbstractListService implements ServiceInterface
22
{
23
    /**
24
     * @var RepositoryInterface $repository
25
     */
26
    protected $repository;
27
28
    /**
29
     * @var array $filters
30
     */
31
    protected $filters;
32
33
    /**
34
     * @var LoggerInterface $logger
35
     */
36
    protected $logger;
37
38
    /**
39
     * AbstractListService constructor.
40
     * @param RepositoryInterface $repository
41
     * @param array $filters
42
     * @param LoggerInterface $logger
43
     */
44
    public function __construct(RepositoryInterface $repository, array $filters, LoggerInterface $logger)
45
    {
46
        $this->repository = $repository;
47
        $this->filters = $filters;
48
        $this->logger = $logger;
49
    }
50
51
    /**
52
     * @return stdClass[]
53
     */
54
    public function run(): array
55
    {
56
        try {
57
            return $this->repository->getList($this->filters);
58
        } catch (Exception $e) {
59
            $this->logger->error($e->getMessage());
60
        }
61
62
        return [];
63
    }
64
}
65