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

PlaisioKernel   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A __get() 0 9 2
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