Completed
Pull Request — develop (#305)
by Wachter
15:11
created

DeleteArticleHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Sulu\Bundle\ArticleBundle\Prooph\Model\Handler;
6
7
use Sulu\Bundle\ArticleBundle\Prooph\Model\Article;
8
use Sulu\Bundle\ArticleBundle\Prooph\Model\ArticleRepositoryInterface;
9
use Sulu\Bundle\ArticleBundle\Prooph\Model\Command\DeleteArticleCommand;
10
11
class DeleteArticleHandler
12
{
13
    /**
14
     * @var ArticleRepositoryInterface
15
     */
16
    private $repository;
17
18
    public function __construct(ArticleRepositoryInterface $repository)
19
    {
20
        $this->repository = $repository;
21
    }
22
23
    public function __invoke(DeleteArticleCommand $command): void
24
    {
25
        $article = $this->repository->get($command->id());
26
27
        $article = $article->remove($command->userId());
28
        $this->repository->save($article);
29
    }
30
}
31