Completed
Push — master ( cfe8fe...f9982c )
by Rougin
04:59
created

ViewValidator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 63.64%

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 4
c 4
b 1
f 0
lcom 1
cbo 0
dl 0
loc 45
ccs 7
cts 11
cp 0.6364
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A fails() 0 12 2
A getMessage() 0 4 1
1
<?php
2
3
namespace Rougin\Combustor\Validator;
4
5
use Rougin\Describe\Describe;
6
use Rougin\Combustor\Validator\ValidatorInterface;
7
8
/**
9
 * View Validator
10
 *
11
 * Checks if it is valid to generate view files.
12
 * 
13
 * @package Combustor
14
 * @author  Rougin Royce Gutib <[email protected]>
15
 */
16
class ViewValidator implements ValidatorInterface
17
{
18
    /**
19
     * @var string
20
     */
21
    protected $name = '';
22
23
    /**
24
     * @var string
25
     */
26
    protected $message = '';
27
28 6
    public function __construct($name)
29
    {
30 6
        $this->name = $name;
31 6
    }
32
33
    /**
34
     * Checks if the validator fails.
35
     * 
36
     * @return boolean
37
     */
38 6
    public function fails()
39
    {
40 6
        $filePath = APPPATH . 'views/' . $this->name;
41
42 6
        if ( ! @mkdir($filePath, 0775, true)) {
43
            $this->message = 'The "' . $this->name . '" views folder already exists!';
44
45
            return true;
46
        }
47
48 6
        return false;
49
    }
50
51
    /**
52
     * Gets the rendered message.
53
     * 
54
     * @return string
55
     */
56
    public function getMessage()
57
    {
58
        return $this->message;
59
    }
60
}
61