MarkArticleAsReadHandler::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
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