Completed
Push — master ( 2d9683...b66861 )
by René
02:54 queued 28s
created

Title::getTitle()   A

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 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Zortje\SEO\Page;
4
5
/**
6
 * Class Title
7
 *
8
 * @package Zortje\SEO\Page
9
 */
10
class Title
11
{
12
13
    /**
14
     * @var string
15
     */
16
    private $title;
17
18
    /**
19
     * @param string $title Page title
20
     */
21 1
    public function setTitle($title)
22
    {
23 1
        $this->title = $title;
24 1
    }
25
26
    /**
27
     * @return string Page title
28
     */
29 1
    public function getTitle()
30
    {
31 1
        return $this->title;
32
    }
33
34
    /**
35
     * Analyze title for issues
36
     *
37
     * @return array Issues; empty if optimized
38
     */
39 3
    public function analyzeForIssues()
40
    {
41 3
        $issues = [];
42
43
        /**
44
         * Length
45
         */
46 3
        if (strlen($this->title) === 0) {
47 1
            $issues[] = 'Title is not set or empty';
48
        }
49
50 3
        if (strlen($this->title) > 55) {
51 1
            $issues[] = 'Title is longer than 55 characters';
52
        }
53
54 3
        return $issues;
55
    }
56
57
}
58