B::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
/**
4
 * PHP: Nelson Martell Library file
5
 *
6
 * Copyright © 2016-2021 Nelson Martell (http://nelson6e65.github.io)
7
 *
8
 * Licensed under The MIT License (MIT)
9
 * For full copyright and license information, please see the LICENSE
10
 * Redistributions of files must retain the above copyright notice.
11
 *
12
 * @copyright 2016-2021 Nelson Martell
13
 * @link      http://nelson6e65.github.io/php_nml/
14
 * @since     v0.6.0
15
 * @license   http://www.opensource.org/licenses/mit-license.php The MIT License (MIT)
16
 * */
17
18
namespace NelsonMartell\Test\DataProviders\ExampleClass;
19
20
use BadMethodCallException;
21
22
class B extends A
23
{
24
    public function __construct()
25
    {
26
        parent::__construct();
27
        unset(
28
            $this->property2,
29
            $this->property4
30
        );
31
    }
32
33
    // This is a wrapper for attribute2
34
    public $property2;
35
36
    /**
37
     * Sets attribute of parent class directly
38
     */
39
    public function setProperty2($value)
40
    {
41
        $this->attribute2 = $value; //This is accesible since is protected
42
    }
43
44
    public $property4;
45
    protected function getProperty4()
46
    {
47
        return $this->attribute4;
48
    }
49
50
    // ERRORS #########################################
51
    /**
52
     * Try to make read-only property accesible in this parent class
53
     * @throws BadMethodCallException
54
     */
55
    protected function setProperty1($value)
56
    {
57
        $this->attribute1 = $value; //This is not accesible since is declared private in A
0 ignored issues
show
Bug Best Practice introduced by
The property $attribute1 is declared private in NelsonMartell\Test\DataProviders\ExampleClass\A. Since you implement __set, consider adding a @property or @property-write.
Loading history...
58
    }
59
}
60