Failed Conditions
Pull Request — master (#25)
by Chad
02:50
created

ComicTest   B

Complexity

Total Complexity 46

Size/Duplication

Total Lines 682
Duplicated Lines 19.94 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 46
lcom 1
cbo 5
dl 136
loc 682
rs 8.0861
c 0
b 0
f 0

32 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 5 1
A getDigitalId() 0 5 1
A getTitle() 0 5 1
A getIssueNumber() 0 5 1
A getVariantDescription() 0 5 1
A getDescription() 0 5 1
A getModified() 0 5 1
A getIsbn() 0 5 1
A getUpc() 0 5 1
A getDiamondCode() 0 5 1
A getEan() 0 5 1
A getIssn() 0 5 1
A getFormat() 0 5 1
A getPageCount() 0 5 1
A getTextObjects() 0 11 2
A getResourceURI() 0 5 1
A getUrls() 10 10 2
A getSeries() 0 9 1
A getEvents() 15 15 2
A getStories() 15 15 2
A getCreators() 15 15 2
A getCharacters() 15 15 2
A getVariants() 12 12 2
A getCollections() 12 12 2
A getCollectedIssues() 12 12 2
A getDates() 10 10 2
A getPrices() 10 10 2
A getThumbnail() 0 7 1
A getImages() 10 10 2
A findAll() 0 10 2
B findAllParametersSetProperly() 0 39 2
B getTestData() 0 137 1

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like ComicTest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use ComicTest, and based on these observations, apply Extract Interface, too.

1
<?php
2
namespace Chadicus\Marvel\Api\Entities;
3
4
use Chadicus\Marvel\Api\Client;
5
use Chadicus\Marvel\Api\Assets\ComicAdapter;
6
7
/**
8
 * Unit tests for the Comic class.
9
 *
10
 * @coversDefaultClass \Chadicus\Marvel\Api\Entities\Comic
11
 * @covers ::<protected>
12
 */
13
final class ComicTest extends \PHPUnit_Framework_TestCase
14
{
15
    /**
16
     * Verify basic behavior of getId.
17
     *
18
     * @test
19
     *
20
     * @return void
21
     */
22
    public function getId()
23
    {
24
        $input = self::getTestData();
25
        $this->assertSame($input['id'], (new Comic($input))->getId());
0 ignored issues
show
Documentation Bug introduced by
The method getId does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
26
    }
27
28
    /**
29
     * Verify basic behavior of getDigitalId.
30
     *
31
     * @test
32
     *
33
     * @return void
34
     */
35
    public function getDigitalId()
36
    {
37
        $input = self::getTestData();
38
        $this->assertSame($input['digitalId'], (new Comic($input))->getDigitalId());
0 ignored issues
show
Documentation Bug introduced by
The method getDigitalId does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
39
    }
40
41
    /**
42
     * Verify basic behavior of getTitle.
43
     *
44
     * @test
45
     *
46
     * @return void
47
     */
48
    public function getTitle()
49
    {
50
        $input = self::getTestData();
51
        $this->assertSame($input['title'], (new Comic($input))->getTitle());
0 ignored issues
show
Documentation Bug introduced by
The method getTitle does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
52
    }
53
54
    /**
55
     * Verify basic behavior of getIssueNumber.
56
     *
57
     * @test
58
     *
59
     * @return void
60
     */
61
    public function getIssueNumber()
62
    {
63
        $input = self::getTestData();
64
        $this->assertSame($input['issueNumber'], (new Comic($input))->getIssueNumber());
0 ignored issues
show
Documentation Bug introduced by
The method getIssueNumber does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
65
    }
66
67
    /**
68
     * Verify basic behavior of getVariantDescription.
69
     *
70
     * @test
71
     *
72
     * @return void
73
     */
74
    public function getVariantDescription()
75
    {
76
        $input = self::getTestData();
77
        $this->assertSame($input['variantDescription'], (new Comic($input))->getVariantDescription());
0 ignored issues
show
Documentation Bug introduced by
The method getVariantDescription does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
78
    }
79
80
    /**
81
     * Verify basic behavior of getDescription.
82
     *
83
     * @test
84
     *
85
     * @return void
86
     */
87
    public function getDescription()
88
    {
89
        $input = self::getTestData();
90
        $this->assertSame($input['description'], (new Comic($input))->getDescription());
0 ignored issues
show
Documentation Bug introduced by
The method getDescription does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
91
    }
92
93
    /**
94
     * Verify basic behavior of getModified.
95
     *
96
     * @test
97
     *
98
     * @return void
99
     */
100
    public function getModified()
101
    {
102
        $input = self::getTestData();
103
        $this->assertSame($input['modified'], (new Comic($input))->getModified()->format('r'));
0 ignored issues
show
Documentation Bug introduced by
The method getModified does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
104
    }
105
106
    /**
107
     * Verify basic behavior of getIsbn.
108
     *
109
     * @test
110
     *
111
     * @return void
112
     */
113
    public function getIsbn()
114
    {
115
        $input = self::getTestData();
116
        $this->assertSame($input['isbn'], (new Comic($input))->getIsbn());
0 ignored issues
show
Documentation Bug introduced by
The method getIsbn does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
117
    }
118
119
    /**
120
     * Verify basic behavior of getUpc.
121
     *
122
     * @test
123
     *
124
     * @return void
125
     */
126
    public function getUpc()
127
    {
128
        $input = self::getTestData();
129
        $this->assertSame($input['upc'], (new Comic($input))->getUpc());
0 ignored issues
show
Documentation Bug introduced by
The method getUpc does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
130
    }
131
132
    /**
133
     * Verify basic behavior of getDiamondCode.
134
     *
135
     * @test
136
     *
137
     * @return void
138
     */
139
    public function getDiamondCode()
140
    {
141
        $input = self::getTestData();
142
        $this->assertSame($input['diamondCode'], (new Comic($input))->getDiamondCode());
0 ignored issues
show
Documentation Bug introduced by
The method getDiamondCode does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
143
    }
144
145
    /**
146
     * Verify basic behavior of getEan.
147
     *
148
     * @test
149
     *
150
     * @return void
151
     */
152
    public function getEan()
153
    {
154
        $input = self::getTestData();
155
        $this->assertSame($input['ean'], (new Comic($input))->getEan());
0 ignored issues
show
Documentation Bug introduced by
The method getEan does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
156
    }
157
158
    /**
159
     * Verify basic behavior of getIssn.
160
     *
161
     * @test
162
     *
163
     * @return void
164
     */
165
    public function getIssn()
166
    {
167
        $input = self::getTestData();
168
        $this->assertSame($input['issn'], (new Comic($input))->getIssn());
0 ignored issues
show
Documentation Bug introduced by
The method getIssn does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
169
    }
170
171
    /**
172
     * Verify basic behavior of getFormat.
173
     *
174
     * @test
175
     *
176
     * @return void
177
     */
178
    public function getFormat()
179
    {
180
        $input = self::getTestData();
181
        $this->assertSame($input['format'], (new Comic($input))->getFormat());
0 ignored issues
show
Documentation Bug introduced by
The method getFormat does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
182
    }
183
184
    /**
185
     * Verify basic behavior of getPageCount.
186
     *
187
     * @test
188
     *
189
     * @return void
190
     */
191
    public function getPageCount()
192
    {
193
        $input = self::getTestData();
194
        $this->assertSame($input['pageCount'], (new Comic($input))->getPageCount());
0 ignored issues
show
Documentation Bug introduced by
The method getPageCount does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
195
    }
196
197
    /**
198
     * Verify basic behavior of getTextObjects.
199
     *
200
     * @test
201
     *
202
     * @return void
203
     */
204
    public function getTextObjects()
205
    {
206
        $input = self::getTestData();
207
        $comic = new Comic($input);
208
        $this->assertSame(count($input['textObjects']), count($comic->getTextObjects()));
0 ignored issues
show
Documentation Bug introduced by
The method getTextObjects does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
209
        foreach ($comic->getTextObjects() as $key => $textObject) {
0 ignored issues
show
Documentation Bug introduced by
The method getTextObjects does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
210
            $this->assertSame($input['textObjects'][$key]['type'], $textObject->getType());
211
            $this->assertSame($input['textObjects'][$key]['language'], $textObject->getLanguage());
212
            $this->assertSame($input['textObjects'][$key]['text'], $textObject->getText());
213
        }
214
    }
215
216
    /**
217
     * Verify basic behavior of getResourceURI.
218
     *
219
     * @test
220
     *
221
     * @return void
222
     */
223
    public function getResourceURI()
224
    {
225
        $input = self::getTestData();
226
        $this->assertSame($input['resourceURI'], (new Comic($input))->getResourceURI());
0 ignored issues
show
Documentation Bug introduced by
The method getResourceURI does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
227
    }
228
229
    /**
230
     * Verify basic behavior of getUrls.
231
     *
232
     * @test
233
     *
234
     * @return void
235
     */
236 View Code Duplication
    public function getUrls()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
237
    {
238
        $input = self::getTestData();
239
        $comic = new Comic($input);
240
        $this->assertSame(count($input['urls']), count($comic->getUrls()));
0 ignored issues
show
Documentation Bug introduced by
The method getUrls does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
241
        foreach ($comic->getUrls() as $key => $url) {
0 ignored issues
show
Documentation Bug introduced by
The method getUrls does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
242
            $this->assertSame($input['urls'][$key]['type'], $url->getType());
243
            $this->assertSame($input['urls'][$key]['url'], $url->getUrl());
244
        }
245
    }
246
247
    /**
248
     * Verify basic behavior of getSeries.
249
     *
250
     * @test
251
     *
252
     * @return void
253
     */
254
    public function getSeries()
255
    {
256
        $input = self::getTestData();
257
        $comic = new Comic($input);
258
        $this->assertSame($input['series']['resourceURI'], $comic->getSeries()->getResourceURI());
0 ignored issues
show
Documentation Bug introduced by
The method getSeries does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
259
        $this->assertSame($input['series']['name'], $comic->getSeries()->getName());
0 ignored issues
show
Documentation Bug introduced by
The method getSeries does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
260
        $this->assertSame($input['series']['type'], $comic->getSeries()->getType());
0 ignored issues
show
Documentation Bug introduced by
The method getSeries does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
261
        $this->assertSame($input['series']['role'], $comic->getSeries()->getRole());
0 ignored issues
show
Documentation Bug introduced by
The method getSeries does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
262
    }
263
264
    /**
265
     * Verify basic behavior of getEvents.
266
     *
267
     * @test
268
     *
269
     * @return void
270
     */
271 View Code Duplication
    public function getEvents()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
272
    {
273
        $input = self::getTestData();
274
        $comic = new Comic($input);
275
        $this->assertSame($input['events']['collectionURI'], $comic->getEvents()->getCollectionURI());
0 ignored issues
show
Documentation Bug introduced by
The method getEvents does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
276
        $this->assertSame($input['events']['available'], $comic->getEvents()->getAvailable());
0 ignored issues
show
Documentation Bug introduced by
The method getEvents does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
277
        $this->assertSame($input['events']['returned'], $comic->getEvents()->getReturned());
0 ignored issues
show
Documentation Bug introduced by
The method getEvents does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
278
        $this->assertSame(count($input['events']['items']), count($comic->getEvents()->getItems()));
0 ignored issues
show
Documentation Bug introduced by
The method getEvents does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
279
        foreach ($comic->getEvents()->getItems() as $key => $item) {
0 ignored issues
show
Documentation Bug introduced by
The method getEvents does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
280
            $this->assertSame($input['events']['items'][$key]['resourceURI'], $item->getResourceURI());
281
            $this->assertSame($input['events']['items'][$key]['name'], $item->getName());
282
            $this->assertSame($input['events']['items'][$key]['type'], $item->getType());
283
            $this->assertSame($input['events']['items'][$key]['role'], $item->getRole());
284
        }
285
    }
286
287
    /**
288
     * Verify basic behavior of getStories.
289
     *
290
     * @test
291
     *
292
     * @return void
293
     */
294 View Code Duplication
    public function getStories()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
295
    {
296
        $input = self::getTestData();
297
        $comic = new Comic($input);
298
        $this->assertSame($input['stories']['collectionURI'], $comic->getStories()->getCollectionURI());
0 ignored issues
show
Documentation Bug introduced by
The method getStories does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
299
        $this->assertSame($input['stories']['available'], $comic->getStories()->getAvailable());
0 ignored issues
show
Documentation Bug introduced by
The method getStories does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
300
        $this->assertSame($input['stories']['returned'], $comic->getStories()->getReturned());
0 ignored issues
show
Documentation Bug introduced by
The method getStories does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
301
        $this->assertSame(count($input['stories']['items']), count($comic->getStories()->getItems()));
0 ignored issues
show
Documentation Bug introduced by
The method getStories does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
302
        foreach ($comic->getStories()->getItems() as $key => $item) {
0 ignored issues
show
Documentation Bug introduced by
The method getStories does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
303
            $this->assertSame($input['stories']['items'][$key]['resourceURI'], $item->getResourceURI());
304
            $this->assertSame($input['stories']['items'][$key]['name'], $item->getName());
305
            $this->assertSame($input['stories']['items'][$key]['type'], $item->getType());
306
            $this->assertSame($input['stories']['items'][$key]['role'], $item->getRole());
307
        }
308
    }
309
310
    /**
311
     * Verify basic behavior of getCreators.
312
     *
313
     * @test
314
     *
315
     * @return void
316
     */
317 View Code Duplication
    public function getCreators()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
318
    {
319
        $input = self::getTestData();
320
        $comic = new Comic($input);
321
        $this->assertSame($input['creators']['collectionURI'], $comic->getCreators()->getCollectionURI());
0 ignored issues
show
Documentation Bug introduced by
The method getCreators does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
322
        $this->assertSame($input['creators']['available'], $comic->getCreators()->getAvailable());
0 ignored issues
show
Documentation Bug introduced by
The method getCreators does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
323
        $this->assertSame($input['creators']['returned'], $comic->getCreators()->getReturned());
0 ignored issues
show
Documentation Bug introduced by
The method getCreators does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
324
        $this->assertSame(count($input['creators']['items']), count($comic->getCreators()->getItems()));
0 ignored issues
show
Documentation Bug introduced by
The method getCreators does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
325
        foreach ($comic->getCreators()->getItems() as $key => $item) {
0 ignored issues
show
Documentation Bug introduced by
The method getCreators does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
326
            $this->assertSame($input['creators']['items'][$key]['resourceURI'], $item->getResourceURI());
327
            $this->assertSame($input['creators']['items'][$key]['name'], $item->getName());
328
            $this->assertSame($input['creators']['items'][$key]['type'], $item->getType());
329
            $this->assertSame($input['creators']['items'][$key]['role'], $item->getRole());
330
        }
331
    }
332
333
    /**
334
     * Verify basic behavior of getCharacters.
335
     *
336
     * @test
337
     *
338
     * @return void
339
     */
340 View Code Duplication
    public function getCharacters()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
341
    {
342
        $input = self::getTestData();
343
        $comic = new Comic($input);
344
        $this->assertSame($input['characters']['collectionURI'], $comic->getCharacters()->getCollectionURI());
0 ignored issues
show
Documentation Bug introduced by
The method getCharacters does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
345
        $this->assertSame($input['characters']['available'], $comic->getCharacters()->getAvailable());
0 ignored issues
show
Documentation Bug introduced by
The method getCharacters does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
346
        $this->assertSame($input['characters']['returned'], $comic->getCharacters()->getReturned());
0 ignored issues
show
Documentation Bug introduced by
The method getCharacters does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
347
        $this->assertSame(count($input['characters']['items']), count($comic->getCharacters()->getItems()));
0 ignored issues
show
Documentation Bug introduced by
The method getCharacters does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
348
        foreach ($comic->getCharacters()->getItems() as $key => $item) {
0 ignored issues
show
Documentation Bug introduced by
The method getCharacters does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
349
            $this->assertSame($input['characters']['items'][$key]['resourceURI'], $item->getResourceURI());
350
            $this->assertSame($input['characters']['items'][$key]['name'], $item->getName());
351
            $this->assertSame($input['characters']['items'][$key]['type'], $item->getType());
352
            $this->assertSame($input['characters']['items'][$key]['role'], $item->getRole());
353
        }
354
    }
355
356
    /**
357
     * Verify basic behavior of getVariants.
358
     *
359
     * @test
360
     *
361
     * @return void
362
     */
363 View Code Duplication
    public function getVariants()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
364
    {
365
        $input = self::getTestData();
366
        $comic = new Comic($input);
367
        $this->assertSame(count($input['variants']), count($comic->getVariants()));
0 ignored issues
show
Documentation Bug introduced by
The method getVariants does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
368
        foreach ($comic->getVariants() as $key => $variant) {
0 ignored issues
show
Documentation Bug introduced by
The method getVariants does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
369
            $this->assertSame($input['variants'][$key]['resourceURI'], $variant->getResourceURI());
370
            $this->assertSame($input['variants'][$key]['name'], $variant->getName());
371
            $this->assertSame($input['variants'][$key]['type'], $variant->getType());
372
            $this->assertSame($input['variants'][$key]['role'], $variant->getRole());
373
        }
374
    }
375
376
    /**
377
     * Verify basic behavior of getCollections.
378
     *
379
     * @test
380
     *
381
     * @return void
382
     */
383 View Code Duplication
    public function getCollections()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
384
    {
385
        $input = self::getTestData();
386
        $comic = new Comic($input);
387
        $this->assertSame(count($input['collections']), count($comic->getCollections()));
0 ignored issues
show
Documentation Bug introduced by
The method getCollections does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
388
        foreach ($comic->getCollections() as $key => $collection) {
0 ignored issues
show
Documentation Bug introduced by
The method getCollections does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
389
            $this->assertSame($input['collections'][$key]['resourceURI'], $collection->getResourceURI());
390
            $this->assertSame($input['collections'][$key]['name'], $collection->getName());
391
            $this->assertSame($input['collections'][$key]['type'], $collection->getType());
392
            $this->assertSame($input['collections'][$key]['role'], $collection->getRole());
393
        }
394
    }
395
396
    /**
397
     * Verify basic behavior of getCollectedIssues.
398
     *
399
     * @test
400
     *
401
     * @return void
402
     */
403 View Code Duplication
    public function getCollectedIssues()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
404
    {
405
        $input = self::getTestData();
406
        $comic = new Comic($input);
407
        $this->assertSame(count($input['collectedIssues']), count($comic->getCollectedIssues()));
0 ignored issues
show
Documentation Bug introduced by
The method getCollectedIssues does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
408
        foreach ($comic->getCollectedIssues() as $key => $issue) {
0 ignored issues
show
Documentation Bug introduced by
The method getCollectedIssues does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
409
            $this->assertSame($input['collectedIssues'][$key]['resourceURI'], $issue->getResourceURI());
410
            $this->assertSame($input['collectedIssues'][$key]['name'], $issue->getName());
411
            $this->assertSame($input['collectedIssues'][$key]['type'], $issue->getType());
412
            $this->assertSame($input['collectedIssues'][$key]['role'], $issue->getRole());
413
        }
414
    }
415
416
    /**
417
     * Verify basic behavior of getDates.
418
     *
419
     * @test
420
     *
421
     * @return void
422
     */
423 View Code Duplication
    public function getDates()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
424
    {
425
        $input = self::getTestData();
426
        $comic = new Comic($input);
427
        $this->assertSame(count($input['dates']), count($comic->getDates()));
0 ignored issues
show
Documentation Bug introduced by
The method getDates does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
428
        foreach ($comic->getDates() as $key => $date) {
0 ignored issues
show
Documentation Bug introduced by
The method getDates does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
429
            $this->assertSame($input['dates'][$key]['date'], $date->getDate()->format('r'));
430
            $this->assertSame($input['dates'][$key]['type'], $date->getType());
431
        }
432
    }
433
434
    /**
435
     * Verify basic behavior of getPrices.
436
     *
437
     * @test
438
     *
439
     * @return void
440
     */
441 View Code Duplication
    public function getPrices()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
442
    {
443
        $input = self::getTestData();
444
        $comic = new Comic($input);
445
        $this->assertSame(count($input['prices']), count($comic->getPrices()));
0 ignored issues
show
Documentation Bug introduced by
The method getPrices does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
446
        foreach ($comic->getPrices() as $key => $date) {
0 ignored issues
show
Documentation Bug introduced by
The method getPrices does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
447
            $this->assertSame($input['prices'][$key]['price'], $date->getPrice());
448
            $this->assertSame($input['prices'][$key]['type'], $date->getType());
449
        }
450
    }
451
452
    /**
453
     * Verify basic behavior of getThumbnail.
454
     *
455
     * @test
456
     *
457
     * @return void
458
     */
459
    public function getThumbnail()
460
    {
461
        $input = self::getTestData();
462
        $comic = new Comic($input);
463
        $this->assertSame($input['thumbnail']['path'], $comic->getThumbnail()->getPath());
0 ignored issues
show
Documentation Bug introduced by
The method getThumbnail does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
464
        $this->assertSame($input['thumbnail']['extension'], $comic->getThumbnail()->getExtension());
0 ignored issues
show
Documentation Bug introduced by
The method getThumbnail does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
465
    }
466
467
    /**
468
     * Verify basic behavior of getImages.
469
     *
470
     * @test
471
     *
472
     * @return void
473
     */
474 View Code Duplication
    public function getImages()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
475
    {
476
        $input = self::getTestData();
477
        $comic = new Comic($input);
478
        $this->assertSame(count($input['images']), count($comic->getImages()));
0 ignored issues
show
Documentation Bug introduced by
The method getImages does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
479
        foreach ($comic->getImages() as $key => $image) {
0 ignored issues
show
Documentation Bug introduced by
The method getImages does not exist on object<Chadicus\Marvel\Api\Entities\Comic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
480
            $this->assertSame($input['images'][$key]['path'], $image->getPath());
481
            $this->assertSame($input['images'][$key]['extension'], $image->getExtension());
482
        }
483
    }
484
485
    /**
486
     * Verify basic behavior of findAll().
487
     *
488
     * @test
489
     * @covers ::findAll
490
     *
491
     * @return void
492
     */
493
    public function findAll()
494
    {
495
        $client = new Client('not under test', 'not under test', new ComicAdapter());
496
        $comics = Comic::findAll($client, []);
497
498
        $this->assertSame(5, $comics->count());
499
        foreach ($comics as $key => $comic) {
500
            $this->assertSame($key + 1, $comic->getId());
501
        }
502
    }
503
504
    /**
505
     * Verify query parameters are set properly with findAll().
506
     *
507
     * @test
508
     * @covers ::findAll
509
     *
510
     * @return void
511
     */
512
    public function findAllParametersSetProperly()
513
    {
514
        $now = new \DateTime();
515
        $toDate = new \DateTime('-2 days');
516
        $fromDate = new \DateTime('-3 days');
517
        $criteria = [
518
            'noVariants' => true,
519
            'hasDigitalIssue' => false,
520
            'modifiedSince' => $now->format('r'),
521
            'series' => [2, 4, 6],
522
            'events' => [1, 3, 5],
523
            'stories' => [7, 8, 9],
524
            'characters' => [2, 3, 4],
525
            'creators' => [5, 6, 7],
526
            'toDate' => $toDate->format('r'),
527
            'fromDate' => $fromDate->format('r'),
528
        ];
529
        $adapter = new ComicAdapter();
530
        $client = new Client('not under test', 'not under test', $adapter);
531
        $comics = Comic::findAll($client, $criteria);
532
533
        $comics->next();
534
535
        $expectedParameters = [
536
            'noVariants' => 'true',
537
            'hasDigitalIssue' => 'false',
538
            'modifiedSince' => $now->format('c'),
539
            'series' => '2,4,6',
540
            'events' => '1,3,5',
541
            'stories' => '7,8,9',
542
            'characters' => '2,3,4',
543
            'creators' => '5,6,7',
544
            'dateRange' => "{$fromDate->format('c')},{$toDate->format('c')}",
545
        ];
546
547
        foreach ($expectedParameters as $key => $value) {
548
            $this->assertSame($value, $adapter->parameters[$key]);
549
        }
550
    }
551
552
    /**
553
     * Helper method to return test comic input data
554
     *
555
     * @return array
556
     */
557
    private static function getTestData()
558
    {
559
        return [
560
            'id' => 1,
561
            'digitalId' => 2,
562
            'title' => 'a title',
563
            'issueNumber' => '3',
564
            'variantDescription' => 'a variant description',
565
            'description' => 'a description',
566
            'modified' => 'Fri, 19 Jun 2015 15:54:05 -0400',
567
            'isbn' => 'an isbn',
568
            'upc' => 'a upc',
569
            'diamondCode' => 'a diamond code',
570
            'ean' => 'an ean',
571
            'issn' => 'an issn',
572
            'format' => 'a format',
573
            'pageCount' => 4,
574
            'textObjects' => [
575
                [
576
                    'type' => 'a text object type',
577
                    'language' => 'a language',
578
                    'text' => 'a text',
579
                ],
580
            ],
581
            'resourceURI' => 'a resource URI',
582
            'urls' => [
583
                [
584
                    'type' => 'a url type',
585
                    'url' => 'a url',
586
                ],
587
            ],
588
            'series' => [
589
                'resourceURI' => 'a series resource URI',
590
                'name' => 'a series name',
591
                'type' => 'a series type',
592
                'role' => 'a series role',
593
            ],
594
            'events' => [
595
                'available' => 1,
596
                'returned' => 1,
597
                'collectionURI' => 'an events collection uri',
598
                'items' => [
599
                    [
600
                        'resourceURI' => 'a event resource URI',
601
                        'name' => 'a event name',
602
                        'type' => 'a event type',
603
                        'role' => 'a event role',
604
                    ]
605
                ],
606
            ],
607
            'stories' => [
608
                'available' => 1,
609
                'returned' => 1,
610
                'collectionURI' => 'an stories collection uri',
611
                'items' => [
612
                    [
613
                        'resourceURI' => 'a story resource URI',
614
                        'name' => 'a story name',
615
                        'type' => 'a story type',
616
                        'role' => 'a story role',
617
                    ]
618
                ],
619
            ],
620
            'creators' => [
621
                'available' => 1,
622
                'returned' => 1,
623
                'collectionURI' => 'an creators collection uri',
624
                'items' => [
625
                    [
626
                        'resourceURI' => 'a creator resource URI',
627
                        'name' => 'a creator name',
628
                        'type' => 'a creator type',
629
                        'role' => 'a creator role',
630
                    ]
631
                ],
632
            ],
633
            'characters' => [
634
                'available' => 1,
635
                'returned' => 1,
636
                'collectionURI' => 'an characters collection uri',
637
                'items' => [
638
                    [
639
                        'resourceURI' => 'a character resource URI',
640
                        'name' => 'a character name',
641
                        'type' => 'a character type',
642
                        'role' => 'a character role',
643
                    ]
644
                ],
645
            ],
646
            'variants' => [
647
                [
648
                    'resourceURI' => 'a variant resource URI',
649
                    'name' => 'a variant name',
650
                    'type' => 'a variant type',
651
                    'role' => 'a variant role',
652
                ],
653
            ],
654
            'collections' => [
655
                [
656
                    'resourceURI' => 'a collection resource URI',
657
                    'name' => 'a collection name',
658
                    'type' => 'a collection type',
659
                    'role' => 'a collection role',
660
                ],
661
            ],
662
            'collectedIssues' => [
663
                [
664
                    'resourceURI' => 'a collected issues resource URI',
665
                    'name' => 'a collected issues name',
666
                    'type' => 'a collected issues type',
667
                    'role' => 'a collected issues role',
668
                ],
669
            ],
670
            'dates' => [
671
                [
672
                    'type' => 'a date type',
673
                    'date' => 'Fri, 31 Jul 2015 08:53:11 -0400',
674
                ],
675
            ],
676
            'prices' => [
677
                [
678
                    'type' => 'a price type',
679
                    'price' => 1.1,
680
                ],
681
            ],
682
            'thumbnail' => [
683
                'path' => 'a thumbnail path',
684
                'extension' => 'a thumbnail extension',
685
            ],
686
            'images' => [
687
                [
688
                    'path' => 'an image path',
689
                    'extension' => 'an image extension',
690
                ],
691
            ],
692
        ];
693
    }
694
}
695