Completed
Push — master ( 080179...458fc2 )
by Derek
02:19
created

Page::displayPage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Subreality\Dilmun\Kishar;
4
5
use Subreality\Dilmun\LoggedClassTrait;
6
7
/**
8
 * Class Page
9
 * @package Subreality\Dilmun\Kishar
10
 */
11
class Page
12
{
13
    use LoggedClassTrait;
14
15
    protected $contents;
16
17
    /**
18
     * Sets the Page's contents to the contents of a file
19
     *
20
     * @param string $contents  The path to the file containing the page's contents
21
     * @return bool             Returns true if the file exists
22
     *                          Returls false if the file does not exist
23
     */
24 3
    public function setContents($contents)
25
    {
26 3
        $contents_exist = file_exists($contents);
27
28 3
        if ($contents_exist) {
29 2
            $this->contents = file_get_contents($contents);
30 2
        } else {
31 1
            $this->contents = false;
32
        }
33
34 3
        return $contents_exist;
35
    }
36
37
    /**
38
     * Echos the contents of a supplied page file
39
     *
40
     * @return void
41
     */
42 1
    public function displayPage()
43
    {
44 1
        echo $this->contents;
45
    }
46
}