Article::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 3
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Pilipinews\Common;
4
5
/**
6
 * Article
7
 *
8
 * @package Pilipinews
9
 * @author  Rougin Gutib <[email protected]>
10
 */
11
class Article
12
{
13
    /**
14
     * @var string
15
     */
16
    protected $body = '';
17
18
    /**
19
     * @var string
20
     */
21
    protected $title = '';
22
23
    /**
24
     * @var string
25
     */
26
    protected $link = '';
27
28
    /**
29
     * Initializes the article instance.
30
     *
31
     * @param string      $title
32
     * @param string      $body
33
     * @param string|null $link
34
     */
35 24
    public function __construct($title, $body, $link = null)
36
    {
37 24
        $this->body = $body;
38
39 24
        $this->title = $title;
40
41 24
        $this->link = $link;
42 24
    }
43
44
    /**
45
     * Returns the body content.
46
     *
47
     * @return string
48
     */
49 6
    public function body()
50
    {
51 6
        return $this->body;
52
    }
53
54
    /**
55
     * Returns the source link.
56
     *
57
     * @return string
58
     */
59 3
    public function link()
60
    {
61 3
        return $this->link;
62
    }
63
64
    /**
65
     * Returns both title and body content.
66
     *
67
     * @return string
68
     */
69 9
    public function post()
70
    {
71 9
        return mb_strtoupper($this->title, 'UTF-8') . "\n\n" . $this->body;
72
    }
73
74
    /**
75
     * Returns the title text.
76
     *
77
     * @return string
78
     */
79 3
    public function title()
80
    {
81 3
        return $this->title;
82
    }
83
}
84