TestScalarDataProvider::getDatetimetzTestData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/*
3
* This file is a part of graphql-youshido project.
4
*
5
* @author Alexandr Viniychuk <[email protected]>
6
* created: 11/28/15 12:05 PM
7
*/
8
9
namespace Youshido\Tests\DataProvider;
10
11
class TestScalarDataProvider
12
{
13
14
15
    public static function getsList()
16
    {
17
        return [
18
            "Int",
19
            "String",
20
            "Boolean",
21
            "Float",
22
            "Id"
23
        ];
24
    }
25
26
    public static function getIntTestData()
27
    {
28
        /** input, serialization, isValid */
29
        return [
30
            [1, 1, true],
31
            [0, 0, true],
32
            [-1, -1, true],
33
            [0.1, 0, false],
34
            [1.1, 1, false],
35
            [[1], 1, false],
36
            [1e5, 100000, false],
37
            ["1", 1, false],
38
            [PHP_INT_MAX - 1, PHP_INT_MAX - 1, true],
39
            [~PHP_INT_MAX + 1, ~PHP_INT_MAX + 1, true],
40
            [1e100, null, false],
41
            [-1e100, null, false],
42
            ['-1.1', -1, false],
43
            ['one', null, false],
44
            [null, null, true],
45
            [false, 0, false],
46
            [true, 1, false],
47
        ];
48
    }
49
50
    public static function getFloatTestData()
51
    {
52
        return [
53
            [1, 1.0, true],
54
            [0, 0.0, true],
55
            [-1, -1, true],
56
            [0.1, 0.1, true],
57
            [1.1, 1.1, true],
58
            ['-1.1', -1.1, false],
59
            ['one', null, false],
60
            [false, 0.0, false],
61
            [null, null, true],
62
            [true, 1.0, false],
63
        ];
64
    }
65
66
    public static function getStringTestData()
67
    {
68
        return [
69
            ["string", "string", true],
70
            [1, "1", true],
71
            [1.1, "1.1", true],
72
            [null, null, true],
73
            [true, "true", true],
74
            [false, "false", true],
75
            [[], null, false],
76
        ];
77
    }
78
79
    public static function getBooleanTestData()
80
    {
81
        return [
82
            ["string", true, false],
83
            ["", false, false],
84
            [1, true, false],
85
            [0, false, false],
86
            [null, false, true],
87
            [true, true, true],
88
            [false, false, true],
89
            [null, null, true],
90
            ["true", true, false],
91
            ["false", false, false],
92
        ];
93
    }
94
95
    public static function getIdTestData()
96
    {
97
        return [
98
            ["string-id", "string-id", true],
99
            ["", null, true],
100
            [1, "1", true],
101
        ];
102
    }
103
104 View Code Duplication
    public static function getDatetimeTestData()
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...
105
    {
106
        $time = time();
107
        return [
108
            [null, null, true],
109
            [(new \DateTime())->setTimestamp($time), date('Y-m-d H:i:s', $time), true],
110
        ];
111
    }
112
113 View Code Duplication
    public static function getDatetimetzTestData()
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...
114
    {
115
        $time = time();
116
        return [
117
            [null, null, true],
118
            [(new \DateTime())->setTimestamp($time), date('r', $time), true],
119
        ];
120
    }
121
122 View Code Duplication
    public static function getDateTestData()
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...
123
    {
124
        $time = time();
125
        return [
126
            [null, null, true],
127
            [(new \DateTime())->setTimestamp($time), date('Y-m-d', $time), true],
128
        ];
129
    }
130
131
132
    public static function getTimestampTestData()
133
    {
134
        $time = time();
135
        return [
136
            [(new \DateTime())->setTimestamp($time), $time, true],
137
            [null, null, true],
138
        ];
139
    }
140
141
}
142