ViewTemplate::getPlaceHolder()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * ViewTemplate is the database model class for the view template table.
5
 *
6
 * @author  Mohamed Alsharaf <[email protected]>
7
 *
8
 * @package viewtemplate
9
 */
10
class ViewTemplate extends DataObject
11
{
12
    private static $db = [
13
        'Title'        => 'Varchar(127)',
14
        'ViewTemplate' => 'Text',
15
    ];
16
17
    /**
18
     * Human-readable singular name.
19
     *
20
     * @var string
21
     * @config
22
     */
23
    private static $singular_name = 'View Template';
24
25
    /**
26
     * Human-readable plural name.
27
     *
28
     * @var string
29
     * @config
30
     */
31
    private static $plural_name = 'View Templates';
32
33
    /**
34
     * Return template placeholder.
35
     *
36
     * @return string
37
     */
38 2
    public function getPlaceHolder()
39
    {
40 2
        return '{{' . $this->Title . '}}';
0 ignored issues
show
Documentation introduced by
The property Title does not exist on object<ViewTemplate>. 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...
41
    }
42
}
43