EditCategoryUseCase::categoryUpdated()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 2
eloc 3
nc 2
nop 0
1
<?php
2
/**
3
 * (c) Tomasz Kunicki <[email protected]>
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
namespace Domain\Category\UseCase\EditCategory;
9
10
use Domain\Category\Repository\CategoryRepositoryInterface;
11
use Domain\Common\UseCase\ResponderAwareInterface;
12
use Domain\Common\UseCase\ResponderAwareTrait;
13
14
/**
15
 * Class EditCategoryUseCase
16
 *
17
 * @package Domain\Category\UseCase\EditCategory
18
 */
19
class EditCategoryUseCase implements ResponderAwareInterface
20
{
21
    use ResponderAwareTrait;
22
23
    /** @var CategoryRepositoryInterface */
24
    private $categoryRepository;
25
26
    /**
27
     * EditCategoryUseCase constructor.
28
     *
29
     * @param CategoryRepositoryInterface $categoryRepository
30
     */
31
    public function __construct(CategoryRepositoryInterface $categoryRepository)
32
    {
33
        $this->categoryRepository = $categoryRepository;
34
    }
35
36
    /**
37
     * @param EditCategoryRequest $request
38
     */
39
    public function execute(EditCategoryRequest $request)
40
    {
41
        $category = $this->categoryRepository->findById($request->getCategoryId());
42
        $category->compose($request->getName());
43
44
        $this->categoryRepository->update($category);
45
46
        $this->categoryUpdated();
47
    }
48
49
    private function categoryUpdated()
50
    {
51
        /** @var EditCategoryResponderInterface $responder */
52
        foreach ($this->responders as $responder) {
53
            $responder->categoryUpdated();
0 ignored issues
show
Bug introduced by
The method categoryUpdated() does not seem to exist on object<Domain\Common\UseCase\ResponderInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
54
        }
55
    }
56
57
}