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

DateTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromArray() 0 13 1
1
<?php
2
namespace Chadicus\Marvel\Api\Entities;
3
4
/**
5
 * Unit tests for the Date class.
6
 *
7
 * @coversDefaultClass \Chadicus\Marvel\Api\Entities\Date
8
 * @covers ::<protected>
9
 */
10
final class DateTest extends \PHPUnit_Framework_TestCase
11
{
12
    /**
13
     * Verify basic behavior of fromArray().
14
     *
15
     * @test
16
     *
17
     * @return void
18
     */
19
    public function fromArray()
20
    {
21
        $now = new \DateTime();
22
        $input = [
23
            'type' => 'a type',
24
            'date' => $now->format('r'),
25
        ];
26
27
        $summary = Date::fromArray($input);
28
29
        $this->assertSame($input['type'], $summary->getType());
0 ignored issues
show
Documentation Bug introduced by
The method getType does not exist on object<Chadicus\Marvel\A...ntities\AbstractEntity>? 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...
30
        $this->assertSame($input['date'], $summary->getDate()->format('r'));
0 ignored issues
show
Documentation Bug introduced by
The method getDate does not exist on object<Chadicus\Marvel\A...ntities\AbstractEntity>? 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...
31
    }
32
}
33