Code Duplication    Length = 107-107 lines in 3 locations

src/Model/Product/ProductCollection.php 1 location

@@ 17-123 (lines=107) @@
14
/**
15
 * @author Kasim Taskin <[email protected]>
16
 */
17
final class ProductCollection implements CreatableFromArray
18
{
19
    /**
20
     * @var int
21
     */
22
    private $page;
23
24
    /**
25
     * @var int
26
     */
27
    private $limit;
28
29
    /**
30
     * @var int
31
     */
32
    private $pages;
33
34
    /**
35
     * @var int
36
     */
37
    private $total;
38
39
    /**
40
     * @var Product[]
41
     */
42
    private $items;
43
44
    private function __construct(
45
        int $page,
46
        int $limit,
47
        int $pages,
48
        int $total,
49
        array $items
50
    ) {
51
        $this->page = $page;
52
        $this->limit = $limit;
53
        $this->pages = $pages;
54
        $this->total = $total;
55
        if ([] !== $items) {
56
            $this->items = $items;
57
        }
58
    }
59
60
    /**
61
     * @return ProductCollection
62
     */
63
    public static function createFromArray(array $data): self
64
    {
65
        $page = -1;
66
        if (isset($data['page'])) {
67
            $page = $data['page'];
68
        }
69
70
        $limit = -1;
71
        if (isset($data['limit'])) {
72
            $limit = $data['limit'];
73
        }
74
75
        $pages = -1;
76
        if (isset($data['pages'])) {
77
            $pages = $data['pages'];
78
        }
79
80
        $total = -1;
81
        if (isset($data['total'])) {
82
            $total = $data['total'];
83
        }
84
85
        /** @var Product[] $items */
86
        $items = [];
87
        if (isset($data['_embedded'], $data['_embedded']['items'])) {
88
            foreach ($data['_embedded']['items'] as $item) {
89
                $items[] = Product::createFromArray($item);
90
            }
91
        }
92
93
        return new self($page, $limit, $pages, $total, $items);
94
    }
95
96
    public function getPage(): int
97
    {
98
        return $this->page;
99
    }
100
101
    public function getLimit(): int
102
    {
103
        return $this->limit;
104
    }
105
106
    public function getPages(): int
107
    {
108
        return $this->pages;
109
    }
110
111
    public function getTotal(): int
112
    {
113
        return $this->total;
114
    }
115
116
    /**
117
     * @return Product[]
118
     */
119
    public function getItems(): array
120
    {
121
        return $this->items;
122
    }
123
}
124

src/Model/Product/TaxonCollection.php 1 location

@@ 18-124 (lines=107) @@
15
/**
16
 * @author Radoje Albijanic <[email protected]>
17
 */
18
final class TaxonCollection implements CreatableFromArray
19
{
20
    /**
21
     * @var int
22
     */
23
    private $page;
24
25
    /**
26
     * @var int
27
     */
28
    private $limit;
29
30
    /**
31
     * @var int
32
     */
33
    private $pages;
34
35
    /**
36
     * @var int
37
     */
38
    private $total;
39
40
    /**
41
     * @var Model[]
42
     */
43
    private $items;
44
45
    private function __construct(
46
        int $page,
47
        int $limit,
48
        int $pages,
49
        int $total,
50
        array $items
51
    ) {
52
        $this->page = $page;
53
        $this->limit = $limit;
54
        $this->pages = $pages;
55
        $this->total = $total;
56
        if ([] !== $items) {
57
            $this->items = $items;
58
        }
59
    }
60
61
    /**
62
     * @return ProductCollection
63
     */
64
    public static function createFromArray(array $data): self
65
    {
66
        $page = -1;
67
        if (isset($data['page'])) {
68
            $page = $data['page'];
69
        }
70
71
        $limit = -1;
72
        if (isset($data['limit'])) {
73
            $limit = $data['limit'];
74
        }
75
76
        $pages = -1;
77
        if (isset($data['pages'])) {
78
            $pages = $data['pages'];
79
        }
80
81
        $total = -1;
82
        if (isset($data['total'])) {
83
            $total = $data['total'];
84
        }
85
86
        /** @var Variant[] $items */
87
        $items = [];
88
        if (isset($data['_embedded'], $data['_embedded']['items'])) {
89
            foreach ($data['_embedded']['items'] as $item) {
90
                $items[] = Variant::createFromArray($item);
91
            }
92
        }
93
94
        return new self($page, $limit, $pages, $total, $items);
95
    }
96
97
    public function getPage(): int
98
    {
99
        return $this->page;
100
    }
101
102
    public function getLimit(): int
103
    {
104
        return $this->limit;
105
    }
106
107
    public function getPages(): int
108
    {
109
        return $this->pages;
110
    }
111
112
    public function getTotal(): int
113
    {
114
        return $this->total;
115
    }
116
117
    /**
118
     * @return Model[]
119
     */
120
    public function getItems(): array
121
    {
122
        return $this->items;
123
    }
124
}
125

src/Model/Product/VariantCollection.php 1 location

@@ 17-123 (lines=107) @@
14
/**
15
 * @author Kasim Taskin <[email protected]>
16
 */
17
final class VariantCollection implements CreatableFromArray
18
{
19
    /**
20
     * @var int
21
     */
22
    private $page;
23
24
    /**
25
     * @var int
26
     */
27
    private $limit;
28
29
    /**
30
     * @var int
31
     */
32
    private $pages;
33
34
    /**
35
     * @var int
36
     */
37
    private $total;
38
39
    /**
40
     * @var Variant[]
41
     */
42
    private $items;
43
44
    private function __construct(
45
        int $page,
46
        int $limit,
47
        int $pages,
48
        int $total,
49
        array $items
50
    ) {
51
        $this->page = $page;
52
        $this->limit = $limit;
53
        $this->pages = $pages;
54
        $this->total = $total;
55
        if ([] !== $items) {
56
            $this->items = $items;
57
        }
58
    }
59
60
    /**
61
     * @return ProductCollection
62
     */
63
    public static function createFromArray(array $data): self
64
    {
65
        $page = -1;
66
        if (isset($data['page'])) {
67
            $page = $data['page'];
68
        }
69
70
        $limit = -1;
71
        if (isset($data['limit'])) {
72
            $limit = $data['limit'];
73
        }
74
75
        $pages = -1;
76
        if (isset($data['pages'])) {
77
            $pages = $data['pages'];
78
        }
79
80
        $total = -1;
81
        if (isset($data['total'])) {
82
            $total = $data['total'];
83
        }
84
85
        /** @var Variant[] $items */
86
        $items = [];
87
        if (isset($data['_embedded'], $data['_embedded']['items'])) {
88
            foreach ($data['_embedded']['items'] as $item) {
89
                $items[] = Variant::createFromArray($item);
90
            }
91
        }
92
93
        return new self($page, $limit, $pages, $total, $items);
94
    }
95
96
    public function getPage(): int
97
    {
98
        return $this->page;
99
    }
100
101
    public function getLimit(): int
102
    {
103
        return $this->limit;
104
    }
105
106
    public function getPages(): int
107
    {
108
        return $this->pages;
109
    }
110
111
    public function getTotal(): int
112
    {
113
        return $this->total;
114
    }
115
116
    /**
117
     * @return Variant[]
118
     */
119
    public function getItems(): array
120
    {
121
        return $this->items;
122
    }
123
}
124