Completed
Push — master ( 446f2e...32b2c3 )
by Nelson
11:26
created

PropertiesHandlerTestProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
dl 0
loc 61
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getAccesiblePropertiesProvider() 0 17 1
A setAccesiblePropertiesProvider() 0 13 1
A unaccesiblePropertiesProvider() 0 21 1
1
<?php
2
/**
3
 * PHP: Nelson Martell Library file
4
 *
5
 * Content:
6
 * - Trait definition.
7
 *
8
 * Copyright © 2016 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 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 \InvalidArgumentException;
24
25
/**
26
 * Data providers for NelsonMartell\Test\TestCase\PropertiesHandlerTest.
27
 *
28
 * @author Nelson Martell <[email protected]>
29
 * @internal
30
 * */
31
trait PropertiesHandlerTestProvider
32
{
33
    use ExporterPlugin;
34
35
    public function getAccesiblePropertiesProvider()
36
    {
37
        $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...
38
        $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...
39
        $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...
40
        $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...
41
        return [
42
            'Get property accesible via a wrapper'        => [-1, $a, 'property1'],
43
            'Get property accesible using attribute name' => [-2, $a, 'attribute2'],
44
            'Get property accesible from parent only'     => [-4, $b, 'property4'],
45
            'Custom prefix: Own attribute directly'       => [(-5 * 2), $c, 'attribute5'],
46
            'Custom prefix: Own property directly'        => [-6, $c, 'property6'],
47
            'Custom prefix: Own property directly2'        => [-9, $d, 'property9'],
48
            'Custom prefix: Parent property'              => [-1, $d, 'property1'],
49
            'Custom prefix: Parent property (using default prefix)' => [-3, $c, 'property3'],
50
        ];
51
    }
52
53
    /**
54
     * testSetAccesibleProperties
55
     */
56
    public function setAccesiblePropertiesProvider()
57
    {
58
        $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...
59
        $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...
60
        $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...
61
        $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...
62
63
        return [
64
            'Public read-write property: Set attribute with setter'            => [(3 * 100), $a, 'property3', 3],
65
            'Set parent attribute accesible from parent (write-only property)' => [null, $b, 'property2', 2],
66
            'Custom prefix: Own property'                                      => [(6 * 99), $c, 'property6', 6],
67
        ];
68
    }
69
70
    public function unaccesiblePropertiesProvider()
71
    {
72
        $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...
73
        $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...
74
        $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...
75
        $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...
76
77
        return [
78
            'Get inexistent property in base'      => [$a, 'property4'],
79
            'Get inexistent property in child'     => [$b, 'property5'],
80
            'Set inexistent property'              => [$a, 'property6', 6],
81
            'Set read-only property'               => [$b, 'property4', 4],
82
            'Set read-only attribute'              => [$a, 'attribute4', 4],
83
            'Set write-only property'              => [$a, 'property2', 2],
84
            'Set unaccesible property from parent' => [$b, 'property1', 1],
85
            'Existent, but wrong prefixes'         => [$b, 'property7'],
86
            'Existent, but wrong prefixes'         => [$b, 'property7', 7],
87
            'Double definition of custom getter prefix: D::C' => [$d, 'property6'],
88
            'Double definition of custom setter prefix: D::C' => [$d, 'property6', 6],
89
        ];
90
    }
91
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
92