Passed
Push — master ( 99c812...113862 )
by P.R.
02:15
created

PlaisioKernel::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace Plaisio;
5
6
/**
7
 * The heart of the PhpPlaisio system and parent class for all kernels.
8
 */
9
abstract class PlaisioKernel extends PlaisioObject
10
{
11
  //--------------------------------------------------------------------------------------------------------------------
12
  /**
13
   * PlaisioKernel constructor.
14
   */
15 2
  public function __construct()
16
  {
17 2
    $this->nub = $this;
18
19 2
    parent::__construct($this);
20 2
  }
21
22
  //--------------------------------------------------------------------------------------------------------------------
23
  /**
24
   * Returns the value of a property.
25
   *
26
   * Do not call this method directly as it is a PHP magic method that
27
   * will be implicitly called when executing `$value = $object->property;`.
28
   *
29
   * @param string $property The name of the property.
30
   *
31
   * @return mixed The value of the property.
32
   *
33
   * @throws \LogicException If the property is not defined.
34
   */
35 2
  public function __get(string $property)
36
  {
37 2
    $getter = 'get'.ucfirst($property);
38 2
    if (method_exists($this, $getter))
39
    {
40 1
      return $this->$property = $this->$getter();
41
    }
42
43 1
    throw new \LogicException(sprintf('Unknown property %s::%s', __CLASS__, $property));
44
  }
45
46
  //--------------------------------------------------------------------------------------------------------------------
47
}
48
49
//----------------------------------------------------------------------------------------------------------------------
50