Code Duplication    Length = 60-62 lines in 4 locations

src/Mailgun/Resource/Api/Domain/CredentialResponse.php 1 location

@@ 17-77 (lines=61) @@
14
/**
15
 * @author Sean Johnson <[email protected]>
16
 */
17
final class CredentialResponse implements ApiResponse
18
{
19
    /**
20
     * @var int
21
     */
22
    private $totalCount;
23
24
    /**
25
     * @var CredentialResponseItem[]
26
     */
27
    private $items;
28
29
    /**
30
     * @param array $data
31
     *
32
     * @return self
33
     */
34
    public static function create(array $data)
35
    {
36
        $items = [];
37
        if (isset($data['items'])) {
38
            foreach ($data['items'] as $item) {
39
                $items[] = CredentialResponseItem::create($item);
40
            }
41
        }
42
43
        if (isset($data['total_count'])) {
44
            $count = $data['total_count'];
45
        } else {
46
            $count = count($items);
47
        }
48
49
        return new self($count, $items);
50
    }
51
52
    /**
53
     * @param int                      $totalCount
54
     * @param CredentialResponseItem[] $items
55
     */
56
    private function __construct($totalCount, array $items)
57
    {
58
        $this->totalCount = $totalCount;
59
        $this->items = $items;
60
    }
61
62
    /**
63
     * @return int
64
     */
65
    public function getTotalCount()
66
    {
67
        return $this->totalCount;
68
    }
69
70
    /**
71
     * @return CredentialResponseItem[]
72
     */
73
    public function getCredentials()
74
    {
75
        return $this->items;
76
    }
77
}
78

src/Mailgun/Resource/Api/Domain/IndexResponse.php 1 location

@@ 17-78 (lines=62) @@
14
/**
15
 * @author Sean Johnson <[email protected]>
16
 */
17
final class IndexResponse implements ApiResponse
18
{
19
    /**
20
     * @var int
21
     */
22
    private $totalCount;
23
24
    /**
25
     * @var Domain[]
26
     */
27
    private $items;
28
29
    /**
30
     * @param array $data
31
     *
32
     * @return self
33
     */
34
    public static function create(array $data)
35
    {
36
        $items = [];
37
38
        if (isset($data['items'])) {
39
            foreach ($data['items'] as $item) {
40
                $items[] = Domain::create($item);
41
            }
42
        }
43
44
        if (isset($data['total_count'])) {
45
            $count = $data['total_count'];
46
        } else {
47
            $count = count($items);
48
        }
49
50
        return new self($count, $items);
51
    }
52
53
    /**
54
     * @param int      $totalCount
55
     * @param Domain[] $items
56
     */
57
    private function __construct($totalCount, array $items)
58
    {
59
        $this->totalCount = $totalCount;
60
        $this->items = $items;
61
    }
62
63
    /**
64
     * @return int
65
     */
66
    public function getTotalCount()
67
    {
68
        return $this->totalCount;
69
    }
70
71
    /**
72
     * @return Domain[]
73
     */
74
    public function getDomains()
75
    {
76
        return $this->items;
77
    }
78
}
79

src/Mailgun/Resource/Api/Stats/AllResponse.php 1 location

@@ 17-77 (lines=61) @@
14
/**
15
 * @author Tobias Nyholm <[email protected]>
16
 */
17
final class AllResponse implements ApiResponse
18
{
19
    /**
20
     * @var int
21
     */
22
    private $totalCount;
23
24
    /**
25
     * @var AllResponseItem[]
26
     */
27
    private $items;
28
29
    /**
30
     * @param int               $totalCount
31
     * @param AllResponseItem[] $items
32
     */
33
    private function __construct($totalCount, array $items)
34
    {
35
        $this->totalCount = $totalCount;
36
        $this->items = $items;
37
    }
38
39
    /**
40
     * @param array $data
41
     *
42
     * @return self
43
     */
44
    public static function create(array $data)
45
    {
46
        $items = [];
47
        if (isset($data['items'])) {
48
            foreach ($data['items'] as $i) {
49
                $items[] = AllResponseItem::create($i);
50
            }
51
        }
52
53
        if (isset($data['total_count'])) {
54
            $count = $data['total_count'];
55
        } else {
56
            $count = count($items);
57
        }
58
59
        return new self($count, $items);
60
    }
61
62
    /**
63
     * @return int
64
     */
65
    public function getTotalCount()
66
    {
67
        return $this->totalCount;
68
    }
69
70
    /**
71
     * @return AllResponseItem[]
72
     */
73
    public function getItems()
74
    {
75
        return $this->items;
76
    }
77
}
78

src/Mailgun/Resource/Api/Routes/Response/IndexResponse.php 1 location

@@ 18-77 (lines=60) @@
15
/**
16
 * @author David Garcia <[email protected]>
17
 */
18
final class IndexResponse implements ApiResponse
19
{
20
    /**
21
     * @var int
22
     */
23
    private $totalCount;
24
25
    /**
26
     * @var RouteDto[]
27
     */
28
    private $items;
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public static function create(array $data)
34
    {
35
        $items = [];
36
37
        if (isset($data['items'])) {
38
            foreach ($data['items'] as $item) {
39
                $items[] = RouteDto::create($item);
40
            }
41
        }
42
43
        if (isset($data['total_count'])) {
44
            $count = $data['total_count'];
45
        } else {
46
            $count = count($items);
47
        }
48
49
        return new self($count, $items);
50
    }
51
52
    /**
53
     * @param int        $totalCount
54
     * @param RouteDto[] $items
55
     */
56
    private function __construct($totalCount, array $items)
57
    {
58
        $this->totalCount = $totalCount;
59
        $this->items = $items;
60
    }
61
62
    /**
63
     * @return int
64
     */
65
    public function getTotalCount()
66
    {
67
        return $this->totalCount;
68
    }
69
70
    /**
71
     * @return RouteDto[]
72
     */
73
    public function getRoutes()
74
    {
75
        return $this->items;
76
    }
77
}
78