Repository   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 82
rs 10
c 0
b 0
f 0
ccs 0
cts 27
cp 0
wmc 11

6 Methods

Rating   Name   Duplication   Size   Complexity  
A registerFactory() 0 1 1
A getPool() 0 1 1
A __construct() 0 2 1
A getCollectionName() 0 2 2
A get() 0 7 2
A getById() 0 16 4
1
<?php
2
3
/**
4
 * Created by Gorlum 10.02.2017 0:07
5
 */
6
7
namespace Core;
8
9
use \Common\ContainerPlus;
0 ignored issues
show
Bug introduced by
The type \Common\ContainerPlus was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Core\GlobalContainer;
11
use TextEntity;
12
use TextModel;
13
14
/**
15
 * Class Core\Repository
16
 *
17
 * Holds current entity objects
18
 *
19
 * @deprecated
20
 */
21
class Repository {
22
23
  /**
24
   * "Not an Object" marker
25
   */
26
  const NaO = '\\NaO';
27
28
29
  /**
30
   * @var ContainerPlus $_repository
31
   */
32
  protected $_repository;
33
34
 /**
35
   * @var ContainerPlus $_oldRepo
36
   */
37
  protected $_oldRepo;
38
39
  /**
40
   * @var GlobalContainer $gc
41
   */
42
  protected $gc;
43
44
  /**
45
   * Core\Repository constructor.
46
   *
47
   * @param GlobalContainer $gc
48
   */
49
  public function __construct(GlobalContainer $gc) {
50
    $this->gc = $gc;
51
  }
52
53
  /**
54
   * @param TextModel  $model
55
   * @param int|string $id
56
   *
57
   * @return TextEntity
58
   * @deprecated
59
   */
60
  public function getById($model, $id) {
61
62
    // TODO - is_object()
63
64
    // Index is fully qualified class name plus ID like Namespace\ClassName\$id
65
    $entityIndex = get_class($model) . '\\' . $id;
66
    if (!isset($this->_oldRepo[$entityIndex])) {
67
      $entity = $model->loadById($id);
68
      if ($entity && !$entity->isEmpty()) {
69
        $this->_oldRepo[$entityIndex] = $entity;
70
      }
71
    } else {
72
      $entity = $this->_oldRepo[$entityIndex];
73
    }
74
75
    return $entity;
76
  }
77
78
  /**
79
   * Returns collection name for supplied object
80
   *
81
   * @param $object
82
   *
83
   * @return string
84
   */
85
  protected function getCollectionName($object) {
86
    return is_object($object) ? get_class($object) : self::NaO;
87
  }
88
89
  public function get($entityClass, $id) {
90
    $entityIndex = get_class($entityClass) . '\\' . $id;
91
    if(!isset($this->_repository[$entityIndex])) {
92
93
    }
94
95
    return $this->_repository[$entityIndex];
96
  }
97
98
  protected function getPool($entityClass) {
0 ignored issues
show
Unused Code introduced by
The parameter $entityClass is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

98
  protected function getPool(/** @scrutinizer ignore-unused */ $entityClass) {

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

Loading history...
99
100
  }
101
102
  public function registerFactory($factory) {
0 ignored issues
show
Unused Code introduced by
The parameter $factory is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

102
  public function registerFactory(/** @scrutinizer ignore-unused */ $factory) {

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

Loading history...
103
104
  }
105
106
}
107