CDIFactoryContent::__construct()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 28
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 28
rs 8.8571
cc 1
eloc 18
nc 1
nop 0
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
}