Completed
Push — master ( d6446f...d11253 )
by Nelson
05:36
created

readwritePropertiesProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * PHP: Nelson Martell Library file
4
 *
5
 * Content:
6
 * - Trait definition.
7
 *
8
 * Copyright © 2016-2017 Nelson Martell (http://nelson6e65.github.io)
9
 *
10
 * Licensed under The MIT License (MIT)
11
 * For full copyright and license information, please see the LICENSE
12
 * Redistributions of files must retain the above copyright notice.
13
 *
14
 * @copyright 2016-2017 Nelson Martell
15
 * @link      http://nelson6e65.github.io/php_nml/
16
 * @since     v0.6.0
17
 * @license   http://www.opensource.org/licenses/mit-license.php The MIT License (MIT)
18
 * */
19
20
namespace NelsonMartell\Test\DataProviders;
21
22
use NelsonMartell\Test\Helpers\ExporterPlugin;
23
use NelsonMartell\Test\Helpers\ImplementsIStrictPropertiesContainer;
24
use NelsonMartell\Test\Helpers\HasWriteOnlyProperties;
25
use NelsonMartell\Test\Helpers\HasReadOnlyProperties;
26
use NelsonMartell\Test\Helpers\HasReadWriteProperties;
27
use NelsonMartell\Test\Helpers\HasUnaccesibleProperties;
28
use \InvalidArgumentException;
29
30
/**
31
 * Data providers for NelsonMartell\Test\TestCase\PropertiesHandlerTest.
32
 *
33
 * @author Nelson Martell <[email protected]>
34
 * @internal
35
 * */
36
trait PropertiesHandlerTestProvider
37
{
38
    use ExporterPlugin;
39
    use ImplementsIStrictPropertiesContainer;
40
    use HasUnaccesibleProperties;
41
    use HasWriteOnlyProperties;
42
    use HasReadWriteProperties;
43
    use HasReadOnlyProperties;
44
45
    public function objectInstanceProvider()
46
    {
47
        $a = new ExampleClass\A;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $a. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
48
        $b = new ExampleClass\B;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $b. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
49
        $c = new ExampleClass\C;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $c. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
50
        $d = new ExampleClass\D;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
51
52
        return [
53
            [$a],
54
            [$b],
55
            [$c],
56
            [$d],
57
        ];
58
    }
59
60
61
    public function writeonlyPropertiesProvider()
62
    {
63
        $a = new ExampleClass\A;
0 ignored issues
show
Unused Code introduced by
$a 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...
Comprehensibility introduced by
Avoid variables with short names like $a. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
64
        $b = new ExampleClass\B;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $b. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
65
        $c = new ExampleClass\C;
0 ignored issues
show
Unused Code introduced by
$c 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...
Comprehensibility introduced by
Avoid variables with short names like $c. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
66
        $d = new ExampleClass\D;
0 ignored issues
show
Unused Code introduced by
$d 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...
Comprehensibility introduced by
Avoid variables with short names like $d. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
67
68
        return [
69
            'Set parent attribute accesible from parent (write-only property)' => [$b, 'property2', 2],
70
        ];
71
    }
72
73
    public function readwritePropertiesProvider()
74
    {
75
        $a = new ExampleClass\A;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $a. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
76
        $c = new ExampleClass\C;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $c. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
77
        $d = new ExampleClass\D;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
78
79
        return [
80
            'Set attribute with setter'                                     => [$a, 'property3', 3, (3 * 100)],
81
            'Custom prefix (parent using default): Own property directly'   => [$c, 'property6', 6, (6 * 99)],
82
            'Custom prefix (parent using custom): Own property directly'    => [$d, 'property9', -9, -(9 * 10)],
83
            'Custom prefix (parent using default)): Parent property '       => [$c, 'property3', -3, -(3 * 100)],
84
        ];
85
    }
86
87
88
    public function readonlyPropertiesProvider()
89
    {
90
        $a = new ExampleClass\A;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $a. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
91
        $b = new ExampleClass\B;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $b. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
92
        $c = new ExampleClass\C;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $c. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
93
        $d = new ExampleClass\D;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
94
        return [
95
            'Get property accesible via a wrapper'                  => [$a, 'property1', -1],
96
            'Get property accesible using attribute name'           => [$a, 'attribute2', -2],
97
            'Get property accesible from parent only'               => [$b, 'property4', -4],
98
            'Custom prefix: Own attribute directly'                 => [$c, 'attribute5', (-5 * 2)],
99
            'Custom prefix: Parent property'                        => [$d, 'property1', -1],
100
        ];
101
    }
102
103
    public function unaccesiblePropertiesProvider()
104
    {
105
        $a = new ExampleClass\A;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $a. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
106
        $b = new ExampleClass\B;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $b. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
107
        $c = new ExampleClass\C;
0 ignored issues
show
Unused Code introduced by
$c 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...
Comprehensibility introduced by
Avoid variables with short names like $c. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
108
        $d = new ExampleClass\D;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
109
110
        return [
111
            'Get inexistent property in base'      => [$a, 'property4'],
112
            'Get inexistent property in child'     => [$b, 'property5'],
113
            'Set inexistent property'              => [$a, 'property6', 6],
114
            'Set read-only property'               => [$b, 'property4', 4],
115
            'Set read-only attribute'              => [$a, 'attribute4', 4],
116
            'Set write-only property'              => [$a, 'property2', 2],
117
            'Set unaccesible property from parent' => [$b, 'property1', 1],
118
            'Existent, but wrong prefixes'         => [$b, 'property7'],
119
            'Existent, but wrong prefixes'         => [$b, 'property7', 7],
120
            'Double definition of custom getter prefix: D::C' => [$d, 'property6'],
121
            'Double definition of custom setter prefix: D::C' => [$d, 'property6', 6],
122
        ];
123
    }
124
}
125