Completed
Push — develop ( d7c7d4...e90b1b )
by Baptiste
02:32
created

MarkArticleAsReadHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 19
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 10 2
A __construct() 0 3 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace PersonalGalaxy\RSS\Handler;
5
6
use PersonalGalaxy\RSS\{
7
    Command\MarkArticleAsRead,
8
    Repository\ArticleRepository,
9
};
10
11
final class MarkArticleAsReadHandler
12
{
13
    private $repository;
14
15 2
    public function __construct(ArticleRepository $repository)
16
    {
17 2
        $this->repository = $repository;
18 2
    }
19
20 2
    public function __invoke(MarkArticleAsRead $wished): void
21
    {
22 2
        if (!$this->repository->has($wished->link())) {
23 1
            return;
24
        }
25
26
        $this
27 1
            ->repository
28 1
            ->get($wished->link())
29 1
            ->markAsRead();
30 1
    }
31
}
32