Heading   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 1 Features 0
Metric Value
c 5
b 1
f 0
dl 0
loc 26
wmc 2
lcom 0
cbo 0
ccs 5
cts 5
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setHeading() 0 6 1
A getHeading() 0 5 1
1
<?php
2
3
/**
4
 * This file is part of the Axstrad library.
5
 *
6
 * (c) Dan Kempster <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @copyright 2014-2015 Dan Kempster <[email protected]>
12
 */
13
14
namespace Axstrad\Component\Content\Traits;
15
16
/**
17
 * Axstrad\Bundle\ContentBundle\Traits\Heading
18
 *
19
 * Property requirements
20
 *   - $heading = ""
21
 *
22
 * @author Dan Kempster <[email protected]>
23
 * @license MIT
24
 * @package Axstrad/Content
25
 * @since 0.3
26
 */
27
trait Heading
28
{
29
    /**
30
     * Set heading
31
     *
32
     * @param string $heading
33
     * @return self
34
     */
35 18
    public function setHeading($heading)
36
    {
37
        /** @noinspection PhpUndefinedFieldInspection */
38 18
        $this->heading = (string) $heading;
0 ignored issues
show
Bug introduced by
The property heading does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
39 18
        return $this;
40
    }
41
42
    /**
43
     * Get heading
44
     *
45
     * @return string
46
     */
47 13
    public function getHeading()
48
    {
49
        /** @noinspection PhpUndefinedFieldInspection */
50 13
        return $this->heading;
51
    }
52
}
53