TContainer   A
last analyzed

Complexity

Total Complexity 16

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 17
dl 0
loc 56
rs 10
c 2
b 0
f 0
ccs 0
cts 35
cp 0
wmc 16

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __unset() 0 3 2
A __call() 0 2 2
A __isset() 0 4 2
A __set() 0 3 2
A clear() 0 3 2
A _containerTranslatePropertyName() 0 2 1
A __get() 0 4 2
A _getContainer() 0 2 1
A isEmpty() 0 2 2
1
<?php
2
/**
3
 * Created by Gorlum 08.01.2018 15:16
4
 */
5
6
namespace Common\Traits;
7
8
use Common\Interfaces\IContainer;
9
10
trait TContainer {
11
  /**
12
   * @return ?IContainer
13
   */
14
  public function _getContainer() {
15
    return null;
16
  }
17
18
  public function __set($name, $value) {
19
    if (is_object($this->_getContainer())) {
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->_getContainer() targeting Common\Traits\TContainer::_getContainer() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
20
      $this->_getContainer()->__set($this->_containerTranslatePropertyName($name), $value);
21
    }
22
  }
23
24
  public function __isset($name) {
25
    return is_object($this->_getContainer())
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->_getContainer() targeting Common\Traits\TContainer::_getContainer() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
26
      ? $this->_getContainer()->__isset($this->_containerTranslatePropertyName($name))
27
      : null;
28
  }
29
30
  public function __get($name) {
31
    return is_object($this->_getContainer())
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->_getContainer() targeting Common\Traits\TContainer::_getContainer() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
32
      ? $this->_getContainer()->__get($this->_containerTranslatePropertyName($name))
33
      : null;
34
  }
35
36
  public function __unset($name) {
37
    if (is_object($this->_getContainer())) {
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->_getContainer() targeting Common\Traits\TContainer::_getContainer() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
38
      $this->_getContainer()->__unset($this->_containerTranslatePropertyName($name));
39
    }
40
  }
41
42
  /**
43
   * Is container contains no data
44
   *
45
   * @return bool
46
   */
47
  public function isEmpty() {
48
    return is_object($this->_getContainer()) ? $this->_getContainer()->isEmpty() : false;
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->_getContainer() targeting Common\Traits\TContainer::_getContainer() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
49
  }
50
51
  /**
52
   * Clears container contents
53
   */
54
  public function clear() {
55
    if (is_object($this->_getContainer())) {
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->_getContainer() targeting Common\Traits\TContainer::_getContainer() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
56
      $this->_getContainer()->clear();
57
    }
58
  }
59
60
  public function __call($name, $arguments) {
61
    return is_object($this->_getContainer()) ? call_user_func_array([$this->_getContainer(), $name], $arguments) : null;
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->_getContainer() targeting Common\Traits\TContainer::_getContainer() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
62
  }
63
64
  protected function _containerTranslatePropertyName($name) {
65
    return $name;
66
  }
67
68
}
69