Code Duplication    Length = 65-65 lines in 2 locations

src/Model/Product/Image.php 1 location

@@ 17-81 (lines=65) @@
14
/**
15
 * @author Kasim Taskin <[email protected]>
16
 */
17
final class Image implements CreatableFromArray
18
{
19
    /**
20
     * @var int
21
     */
22
    private $id;
23
24
    /**
25
     * @var string
26
     */
27
    private $type;
28
29
    /**
30
     * @var string
31
     */
32
    private $path;
33
34
    private function __construct(
35
        int $id,
36
        string $type,
37
        string $path
38
    ) {
39
        $this->id = $id;
40
        $this->type = $type;
41
        $this->path = $path;
42
    }
43
44
    /**
45
     * @return Product
46
     */
47
    public static function createFromArray(array $data): self
48
    {
49
        $id = -1;
50
        if (isset($data['id'])) {
51
            $id = $data['id'];
52
        }
53
54
        $type = '';
55
        if (isset($data['type'])) {
56
            $type = $data['type'];
57
        }
58
59
        $path = '';
60
        if (isset($data['path'])) {
61
            $path = $data['path'];
62
        }
63
64
        return new self($id, $type, $path);
65
    }
66
67
    public function getId(): int
68
    {
69
        return $this->id;
70
    }
71
72
    public function getType(): string
73
    {
74
        return $this->type;
75
    }
76
77
    public function getPath(): string
78
    {
79
        return $this->path;
80
    }
81
}
82

src/Model/Product/Taxon.php 1 location

@@ 17-81 (lines=65) @@
14
/**
15
 * @author Radoje Albijanic <[email protected]>
16
 */
17
final class Taxon implements CreatableFromArray
18
{
19
    /**
20
     * @var int
21
     */
22
    private $id;
23
24
    /**
25
     * @var string
26
     */
27
    private $code;
28
29
    /**
30
     * @var string[][]
31
     */
32
    private $translations;
33
34
    private function __construct(
35
        int $id,
36
        string $code,
37
        array $translations
38
    ) {
39
        $this->id = $id;
40
        $this->code = $code;
41
        $this->translations = $translations;
42
    }
43
44
    public static function createFromArray(array $data): self
45
    {
46
        $id = -1;
47
        if (isset($data['id'])) {
48
            $id = $data['id'];
49
        }
50
51
        $code = '';
52
        if (isset($data['code'])) {
53
            $code = $data['code'];
54
        }
55
56
        $translations = [];
57
        if (isset($data['translations'])) {
58
            $translations = $data['translations'];
59
        }
60
61
        return new self($id, $code, $translations);
62
    }
63
64
    public function getId(): int
65
    {
66
        return $this->id;
67
    }
68
69
    public function getCode(): string
70
    {
71
        return $this->code;
72
    }
73
74
    /**
75
     * @return \string[][]
76
     */
77
    public function getTranslations(): array
78
    {
79
        return $this->translations;
80
    }
81
}
82