CategoryPatchMessage   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A createFromCategory() 0 14 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Yproximite\Api\Message\Article;
5
6
use Yproximite\Api\Model\Article\Category;
7
use Yproximite\Api\Message\IdentityAwareMessageTrait;
8
9
/**
10
 * Class CategoryPatchMessage
11
 */
12
class CategoryPatchMessage extends AbstractCategoryMessage
13
{
14
    use IdentityAwareMessageTrait;
15
16
    /**
17
     * @param Category $category
18
     *
19
     * @return self
20
     */
21
    public static function createFromCategory(Category $category): self
22
    {
23
        $message = new self();
24
        $message->setId($category->getId());
25
        $message->setEnabled($category->isEnabled());
26
27
        foreach ($category->getTranslations() as $translation) {
28
            $transMessage = CategoryTranslationMessage::createFromCategoryTranslation($translation);
29
30
            $message->addTranslation($transMessage);
31
        }
32
33
        return $message;
34
    }
35
}
36