LocationSpec::it_should_belong_to_a_library()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace spec\Scriptotek\Alma\Conf;
4
5
use PhpSpec\ObjectBehavior;
6
use Scriptotek\Alma\Client as AlmaClient;
7
use Scriptotek\Alma\Conf\Library;
8
use Scriptotek\Alma\Conf\Location;
9
10
class LocationSpec extends ObjectBehavior
11
{
12
    public function let(AlmaClient $client, Library $library)
13
    {
14
        $location_code = 'sq10s9pg';
15
        $this->beConstructedWith($client, $library, $location_code);
16
    }
17
18
    public function it_is_initializable()
19
    {
20
        $this->shouldHaveType(Location::class);
21
    }
22
23
    public function it_should_belong_to_a_library()
24
    {
25
        $this->library->shouldBeAnInstanceOf(Library::class);
0 ignored issues
show
Documentation introduced by
The property library does not exist on object<spec\Scriptotek\Alma\Conf\LocationSpec>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
26
    }
27
}
28