ValueObject   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
eloc 5
c 3
b 0
f 0
dl 0
loc 40
ccs 7
cts 7
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __set() 0 2 1
A __isset() 0 3 1
A __get() 0 7 2
1
<?php
2
3
//----------------------------------------------------------------------
4
//
5
//  Copyright (C) 2015-2022 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
     * @return mixed Current value of the property
39
     *
40
     * @throws \BadMethodCallException If the property doesn't exist
41
     */
42 2
    public function __get(string $name)
43
    {
44 2
        if (!property_exists($this, $name)) {
45 1
            throw new \BadMethodCallException(sprintf('Unknown property "%s" in class "%s".', $name, static::class));
46
        }
47
48 1
        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 1
    final public function __set(string $name, $value)
58
    {
59 1
    }
60
}
61