Controller::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 9.2
c 0
b 0
f 0
ccs 0
cts 18
cp 0
cc 1
eloc 13
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * Controller Manager
5
 *
6
 * @category  	src\BackOffice
7
 * @package   	src\BackOffice\common
8
 * @author    	Judicaël Paquet <[email protected]>
9
 * @copyright 	Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93)
10
 * @license   	https://github.com/las93/uranium/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël
11
 * @version   	Release: 1.0.0
12
 * @filesource	https://github.com/las93/venus2
13
 * @link      	https://github.com/las93
14
 * @since     	1.0
15
 */
16
namespace Venus\src\plugins\common;
17
18
use \Venus\core\Config                  as Config;
19
use \Venus\core\Controller              as CoreController;
20
use \Venus\src\Batch\Controller\Entity  as Entity;
21
22
/**
23
 * Controller Manager
24
 *
25
 * @category  	src\BackOffice
26
 * @package   	src\BackOffice\common
27
 * @author    	Judicaël Paquet <[email protected]>
28
 * @copyright 	Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93)
29
 * @license   	https://github.com/las93/uranium/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël
30
 * @version   	Release: 1.0.0
31
 * @filesource	https://github.com/las93/venus2
32
 * @link      	https://github.com/las93
33
 * @since     	1.0
34
 */
35
abstract class Controller extends CoreController
36
{
37
	/**
38
	 * Constructor
39
	 *
40
	 * @access public
41
	 * @return object
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
42
	 */
43
	public function __construct() 
44
	{
45
		parent::__construct();
46
		
47
		$this->installDb = function()
0 ignored issues
show
Documentation introduced by
The property installDb does not exist on object<Venus\src\plugins\common\Controller>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
48
		{
49
		    $oDb = Config::get('Db');
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $oDb is correct as \Venus\core\Config::get('Db') (which targets Venus\core\Config::get()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

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

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

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

Loading history...
50
		    $oTables = json_decode(file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.preg_replace('/^.*\\\\([a-zA-Z0-9]+)$/', '$1', get_called_class()).DIRECTORY_SEPARATOR.'conf'.DIRECTORY_SEPARATOR.'Db.conf'));
51
		    
52
		    $oDb->configuration->tables = $oTables;
53
		    
54
    	    $aOptions = [
55
	           "p" => CREATE_PORTAL,
56
	           "c" => true,
57
	           "e" => true,
58
	           "b" => json_encode($oDb)
59
    	    ];
60
    	    
61
    	    $oEntity = new Entity;
62
    	    $oEntity->runScaffolding($aOptions);
63
		};
64
	}
65
}
66