Page   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 40
ccs 12
cts 12
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A displayPage() 0 4 1
A setContents() 0 16 2
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
     *                          Returns 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
31 2
            $this->updateLog("info", "Page contents set from {$contents}");
32 2
        } else {
33 1
            $this->contents = false;
34
            
35 1
            $this->updateLog("alert", "File {$contents} not found");
36
        }
37
38 3
        return $contents_exist;
39
    }
40
41
    /**
42
     * Echos the contents of a supplied page file
43
     *
44
     * @return void
45
     */
46 1
    public function displayPage()
47
    {
48 1
        echo $this->contents;
49 1
    }
50
}
51