CDIFactoryContent   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
c 1
b 0
f 1
lcom 0
cbo 5
dl 0
loc 35
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 28 1
1
<?php
2
3
namespace Anax\DI;
4
5
/**
6
 * Extended factory for Anax database content management.
7
 *
8
 */
9
class CDIFactoryContent extends CDIFactoryDefault
10
{
11
   /**
12
     * Construct.
13
     *
14
     */
15
    public function __construct()
16
    {
17
        parent::__construct();
18
19
        $this->setShared('db', function() {
20
			$db = new \Mos\Database\CDatabaseBasic();
21
			$db->setOptions(require ANAX_APP_PATH . 'config/config_mysql.php');
22
			$db->connect();
23
			return $db;
24
		});
25
		
26
		$this->setShared('form', function() {
27
			$form = new \Mos\HTMLForm\CForm();
28
			return $form;
29
		});
30
		
31
		$this->setShared('PageController', function() {
32
			$pageController = new \Anax\Page\PageController();
33
			$pageController->setDI($this);
0 ignored issues
show
Documentation introduced by
$this is of type this<Anax\DI\CDIFactoryContent>, but the function expects a object<Anax\DI\class>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
34
			return $pageController;
35
		});
36
		
37
		$this->setShared('BlogController', function() {
38
			$blogController = new \Anax\Blog\BlogController();
39
			$blogController->setDI($this);
0 ignored issues
show
Documentation introduced by
$this is of type this<Anax\DI\CDIFactoryContent>, but the function expects a object<Anax\DI\class>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
40
			return $blogController;
41
		});
42
    }
43
}