Completed
Push — master ( 1c3927...202e6d )
by Artem
02:05
created

ValueObject::__set()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 0
cp 0
rs 10
cc 1
eloc 1
nc 1
nop 2
crap 2
1
<?php
2
3
//----------------------------------------------------------------------
4
//
5
//  Copyright (C) 2016 Artem Rodygin
6
//
7
//  This file is part of DataTables Symfony bundle.
8
//
9
//  You should have received a copy of the MIT License along with
10
//  the bundle. If not, see <http://opensource.org/licenses/MIT>.
11
//
12
//----------------------------------------------------------------------
13
14
namespace DataTables;
15
16
/**
17
 * Immutable value object.
18
 */
19
class ValueObject
20
{
21
    /**
22
     * Checks whether specified property exists.
23
     *
24
     * @param   string $name Name of the property.
25
     *
26
     * @return  bool TRUE if the property exists, FALSE otherwise.
27
     */
28 1
    public function __isset(string $name): bool
29
    {
30 1
        return property_exists($this, $name);
31
    }
32
33
    /**
34
     * Returns current value of specified property.
35
     *
36
     * @param   string $name Name of the property.
37
     *
38
     * @throws  \BadMethodCallException If the property doesn't exist.
39
     *
40
     * @return  mixed Current value of the property.
41
     */
42 3
    public function __get(string $name)
43
    {
44 3
        if (!property_exists($this, $name)) {
45 1
            throw new \BadMethodCallException(sprintf('Unknown property "%s" in class "%s".', $name, get_class($this)));
46
        }
47
48 2
        return $this->$name;
49
    }
50
51
    /**
52
     * Prevents object's properties from modification.
53
     *
54
     * @param   string $name  Name of the property.
55
     * @param   mixed  $value New value of the property.
56
     */
57
    final public function __set(string $name, $value)
0 ignored issues
show
Unused Code introduced by
The parameter $name is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $value is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
58
    {
59
    }
60
}
61