MarkArticleAsReadHandler::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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