Passed
Push — master ( 537734...074b86 )
by Nelson
03:06
created

HasWriteOnlyProperties::testWriteonlyPropertiesAreNotReadables()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
/**
3
 * PHP: Nelson Martell Library file
4
 *
5
 * Copyright © 2017-2019 Nelson Martell (http://nelson6e65.github.io)
6
 *
7
 * Licensed under The MIT License (MIT)
8
 * For full copyright and license information, please see the LICENSE
9
 * Redistributions of files must retain the above copyright notice.
10
 *
11
 * @copyright 2017-2019 Nelson Martell
12
 * @link      http://nelson6e65.github.io/php_nml/
13
 * @since     v0.7.0
14
 * @license   http://www.opensource.org/licenses/mit-license.php The MIT License (MIT)
15
 * */
16
17
namespace NelsonMartell\Test\Helpers;
18
19
use BadMethodCallException;
20
21
use NelsonMartell\IStrictPropertiesContainer;
22
23
/**
24
 * Split of ImplementsIStrictPropertiesContainer, for classes implementing any write-only property.
25
 *
26
 * @author Nelson Martell <[email protected]>
27
 * */
28
trait HasWriteOnlyProperties
29
{
30
    /**
31
     * @returns IStrictPropertiesContainer
32
     */
33
    abstract public function testImplementsIStrictPropertiesContainerInterface($obj);
34
35
    abstract public function writeonlyPropertiesProvider();
36
37
    /**
38
     * @dataProvider writeonlyPropertiesProvider
39
     *
40
     * @param IStrictPropertiesContainer $obj
41
     * @param string                     $property
42
     * @param mixed                     $value
43
     */
44
    public function testWriteonlyPropertiesAreWritablesAreNotReadables(
45
        IStrictPropertiesContainer $obj,
46
        string $property,
47
        $value
48
    ) : void {
49
        $obj->$property = $value;
50
        $this->addToAssertionCount(1);
0 ignored issues
show
Bug introduced by
It seems like addToAssertionCount() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

50
        $this->/** @scrutinizer ignore-call */ 
51
               addToAssertionCount(1);
Loading history...
51
52
        $this->expectException(BadMethodCallException::class);
0 ignored issues
show
Bug introduced by
It seems like expectException() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

52
        $this->/** @scrutinizer ignore-call */ 
53
               expectException(BadMethodCallException::class);
Loading history...
53
        $actual = $obj->$property;
0 ignored issues
show
Unused Code introduced by
The assignment to $actual is dead and can be removed.
Loading history...
54
    }
55
}
56