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

CharacterTest::construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 79
Code Lines 65

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 79
rs 8.8701
c 0
b 0
f 0
cc 1
eloc 65
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
namespace Chadicus\Marvel\Api\Entities;
3
4
use Chadicus\Marvel\Api\Client;
5
use Chadicus\Marvel\Api\Assets\CharacterAdapter;
6
7
/**
8
 * Unit tests for the Character class.
9
 *
10
 * @coversDefaultClass \Chadicus\Marvel\Api\Entities\Character
11
 * @covers ::<protected>
12
 */
13
final class CharacterTest extends \PHPUnit_Framework_TestCase
14
{
15
    /**
16
     * Verify properties are set properly.
17
     *
18
     * @test
19
     *
20
     * @return void
21
     */
22
    public function construct()
23
    {
24
        $client = new Client('not under test', 'not under test', new CharacterAdapter());
0 ignored issues
show
Unused Code introduced by
$client is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
25
26
        $now = new \DateTime();
27
28
        $data = [
29
            'id' => 1,
30
            'name' => 'a name',
31
            'description' => 'a description',
32
            'modified' => $now->format('r'),
33
            'resourceURI' => 'a resource uri',
34
            'urls' => [['type' => 'a type', 'url' => 'a url']],
35
            'thumbnail' => ['path' => 'a path', 'extension' => 'an extension'],
36
            'comics' => [
37
                'available' => 2,
38
                'returned' => 1,
39
                'collectionURI' => 'a comics collection uri',
40
                'items' => [['resourceURI' => 'a comics resource uri', 'name' => 'a comics name']],
41
            ],
42
            'stories' => [
43
                'available' => 2,
44
                'returned' => 1,
45
                'collectionURI' => 'a stories collection uri',
46
                'items' => [['resourceURI' => 'a stories resource uri', 'name' => 'a stories name']],
47
            ],
48
            'events' => [
49
                'available' => 2,
50
                'returned' => 1,
51
                'collectionURI' => 'a events collection uri',
52
                'items' => [['resourceURI' => 'a events resource uri', 'name' => 'a events name']],
53
            ],
54
            'series' => [
55
                'available' => 2,
56
                'returned' => 1,
57
                'collectionURI' => 'a series collection uri',
58
                'items' => [['resourceURI' => 'a series resource uri', 'name' => 'a series name']],
59
            ],
60
        ];
61
62
        $character = new Character($data);
63
        $this->assertSame(1, $character->getId());
0 ignored issues
show
Documentation Bug introduced by
The method getId does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
64
        $this->assertSame('a name', $character->getName());
0 ignored issues
show
Documentation Bug introduced by
The method getName does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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
        $this->assertSame('a description', $character->getDescription());
0 ignored issues
show
Documentation Bug introduced by
The method getDescription does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
66
        $this->assertSame($now->getTimestamp(), $character->getModified()->getTimestamp());
0 ignored issues
show
Documentation Bug introduced by
The method getModified does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
67
        $this->assertSame('a resource uri', $character->getResourceURI());
0 ignored issues
show
Documentation Bug introduced by
The method getResourceURI does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
68
        $this->assertSame(1, count($character->getUrls()));
0 ignored issues
show
Documentation Bug introduced by
The method getUrls does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
69
        $this->assertSame('a type', $character->getUrls()[0]->getType());
0 ignored issues
show
Documentation Bug introduced by
The method getUrls does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
70
        $this->assertSame('a url', $character->getUrls()[0]->getUrl());
0 ignored issues
show
Documentation Bug introduced by
The method getUrls does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
71
        $this->assertSame('a path', $character->getThumbnail()->getPath());
0 ignored issues
show
Documentation Bug introduced by
The method getThumbnail does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
72
        $this->assertSame('an extension', $character->getThumbnail()->getExtension());
0 ignored issues
show
Documentation Bug introduced by
The method getThumbnail does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
73
74
        $this->assertSame(2, $character->getComics()->getAvailable());
0 ignored issues
show
Documentation Bug introduced by
The method getComics does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
75
        $this->assertSame(1, $character->getComics()->getReturned());
0 ignored issues
show
Documentation Bug introduced by
The method getComics does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
76
        $this->assertSame('a comics collection uri', $character->getComics()->getCollectionURI());
0 ignored issues
show
Documentation Bug introduced by
The method getComics does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
77
        $this->assertSame(1, count($character->getComics()->getItems()));
0 ignored issues
show
Documentation Bug introduced by
The method getComics does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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
        $this->assertSame('a comics resource uri', $character->getComics()->getItems()[0]->getResourceURI());
0 ignored issues
show
Documentation Bug introduced by
The method getComics does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
79
        $this->assertSame('a comics name', $character->getComics()->getItems()[0]->getName());
0 ignored issues
show
Documentation Bug introduced by
The method getComics does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
80
81
        $this->assertSame(2, $character->getStories()->getAvailable());
0 ignored issues
show
Documentation Bug introduced by
The method getStories does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
82
        $this->assertSame(1, $character->getStories()->getReturned());
0 ignored issues
show
Documentation Bug introduced by
The method getStories does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
83
        $this->assertSame(1, count($character->getStories()->getItems()));
0 ignored issues
show
Documentation Bug introduced by
The method getStories does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
84
        $this->assertSame('a stories resource uri', $character->getStories()->getItems()[0]->getResourceURI());
0 ignored issues
show
Documentation Bug introduced by
The method getStories does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
85
        $this->assertSame('a stories name', $character->getStories()->getItems()[0]->getName());
0 ignored issues
show
Documentation Bug introduced by
The method getStories does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
86
87
        $this->assertSame(2, $character->getEvents()->getAvailable());
0 ignored issues
show
Documentation Bug introduced by
The method getEvents does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
88
        $this->assertSame(1, $character->getEvents()->getReturned());
0 ignored issues
show
Documentation Bug introduced by
The method getEvents does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
89
        $this->assertSame('a events collection uri', $character->getEvents()->getCollectionURI());
0 ignored issues
show
Documentation Bug introduced by
The method getEvents does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
90
        $this->assertSame(1, count($character->getEvents()->getItems()));
0 ignored issues
show
Documentation Bug introduced by
The method getEvents does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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
        $this->assertSame('a events resource uri', $character->getEvents()->getItems()[0]->getResourceURI());
0 ignored issues
show
Documentation Bug introduced by
The method getEvents does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
92
        $this->assertSame('a events name', $character->getEvents()->getItems()[0]->getName());
0 ignored issues
show
Documentation Bug introduced by
The method getEvents does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
93
94
        $this->assertSame(2, $character->getSeries()->getAvailable());
0 ignored issues
show
Documentation Bug introduced by
The method getSeries does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
95
        $this->assertSame(1, $character->getSeries()->getReturned());
0 ignored issues
show
Documentation Bug introduced by
The method getSeries does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
96
        $this->assertSame('a series collection uri', $character->getSeries()->getCollectionURI());
0 ignored issues
show
Documentation Bug introduced by
The method getSeries does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
97
        $this->assertSame(1, count($character->getSeries()->getItems()));
0 ignored issues
show
Documentation Bug introduced by
The method getSeries does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
98
        $this->assertSame('a series resource uri', $character->getSeries()->getItems()[0]->getResourceURI());
0 ignored issues
show
Documentation Bug introduced by
The method getSeries does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
99
        $this->assertSame('a series name', $character->getSeries()->getItems()[0]->getName());
0 ignored issues
show
Documentation Bug introduced by
The method getSeries does not exist on object<Chadicus\Marvel\Api\Entities\Character>? 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...
100
    }
101
102
    /**
103
     * Verify basic behavior of findAll().
104
     *
105
     * @test
106
     * @covers ::findAll
107
     *
108
     * @return void
109
     */
110
    public function findAll()
111
    {
112
        $client = new Client('not under test', 'not under test', new CharacterAdapter());
113
        $characters = Character::findAll($client);
114
115
        $this->assertSame(5, $characters->count());
116
        foreach ($characters as $key => $character) {
117
            $this->assertSame($key, $character->getId());
118
            $this->assertSame("a name for character {$key}", $character->getName());
119
            $this->assertSame("a description for character {$key}", $character->getDescription());
120
        }
121
    }
122
123
    /**
124
     * Verify query parameters are set properly with findAll().
125
     *
126
     * @test
127
     * @covers ::findAll
128
     *
129
     * @return void
130
     */
131
    public function findAllParametersSetProperly()
132
    {
133
        $now = new \DateTime();
134
        $criteria = [
135
            'name' => 'a name',
136
            'modifiedSince' => $now->format('r'),
137
            'comics' => [1,2,3],
138
            'series' => [2,4,6],
139
            'events' => [1,3,5],
140
            'stories' => [7,8,9],
141
            'orderBy' => 'name',
142
        ];
143
        $adapter = new CharacterAdapter();
144
        $client = new Client('not under test', 'not under test', $adapter);
145
        $characters = Character::findAll($client, $criteria);
146
147
        $characters->next();
148
149
        $expectedParameters = [
150
            'name' => 'a name',
151
            'modifiedSince' => $now->format('c'),
152
            'comics' => '1,2,3',
153
            'series' => '2,4,6',
154
            'events' => '1,3,5',
155
            'stories' => '7,8,9',
156
            'orderBy' => 'name',
157
        ];
158
159
        foreach ($expectedParameters as $key => $value) {
160
            $this->assertSame($value, $adapter->parameters[$key]);
161
        }
162
    }
163
}
164