Heading::setHeading()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
crap 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