CDIFactoryDocumentation   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 10
c 0
b 0
f 0
ccs 0
cts 10
cp 0
wmc 1
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 1
1
<?php
2
3
namespace Anax\DI;
4
5
/**
6
 * Extended factory for Anax documentation.
7
 *
8
 */
9
class CDIFactoryDocumentation extends CDIFactoryDefault
10
{
11
   /**
12
     * Construct.
13
     *
14
     */
15
    public function __construct()
16
    {
17
        parent::__construct();
18
19
        $this->set('documentation', function () {
20
            $fc = new \Anax\Content\CFileContent();
21
            $fc->setBasePath(ANAX_INSTALL_PATH . 'docs/documentation');
22
            return $fc;
23
        });
24
25
        $this->theme->setVariable('style', "article {max-width: 650px;}");
0 ignored issues
show
Documentation introduced by
The property theme does not exist on object<Anax\DI\CDIFactoryDocumentation>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
26
        $this->theme->setBaseTitle(" - Anax documentation");
0 ignored issues
show
Documentation introduced by
The property theme does not exist on object<Anax\DI\CDIFactoryDocumentation>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
27
    }
28
}
29