DateTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 29
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testFromDateTime() 0 7 1
A testFromDate() 0 7 1
A testJsonSerialize() 0 10 1
1
<?php
2
3
namespace Postpay\Tests\Serializers;
4
5
use DateTime;
6
use PHPUnit\Framework\TestCase;
7
use Postpay\Serializers\Date;
8
9
class DateTest extends TestCase
10
{
11
    public function testFromDateTime()
12
    {
13
        $datetime = new DateTime();
14
        $date = Date::fromDateTime($datetime);
0 ignored issues
show
Documentation introduced by mongkok
$datetime is of type object<DateTime>, but the function expects a object<Postpay\Serializers\DateTime>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
15
16
        self::assertGreaterThanOrEqual($date->toDateTime(), $datetime);
17
    }
18
19
    public function testFromDate()
20
    {
21
        $datetime = new DateTime();
22
        $date = Date::fromDate($datetime);
0 ignored issues
show
Documentation introduced by mongkok
$datetime is of type object<DateTime>, but the function expects a object<Postpay\Serializers\DateTime>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
23
24
        self::assertGreaterThan($date->toDateTime(), $datetime);
25
    }
26
27
    public function testJsonSerialize()
28
    {
29
        $datetime = new DateTime();
30
        $date = Date::fromDateTime($datetime);
0 ignored issues
show
Documentation introduced by mongkok
$datetime is of type object<DateTime>, but the function expects a object<Postpay\Serializers\DateTime>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
31
32
        self::assertSame(
33
            $date->jsonSerialize(),
34
            trim(json_encode($date), '"')
35
        );
36
    }
37
}
38