Readable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 35
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 8 3
1
<?php
2
/**
3
 * Jaeger
4
 *
5
 * @copyright	Copyright (c) 2015-2016, mithra62
6
 * @link		http://jaeger-app.com
7
 * @version		1.0
8
 * @filesource 	./Validate/Filesystem/Readable.php
9
 */
10
namespace JaegerApp\Validate\Rules\Filesystem;
11
12
use JaegerApp\Validate\AbstractRule;
13
14
if (! class_exists('\\JaegerApp\\Validate\\Filesystem\\Readable')) {
15
16
    /**
17
     * Jaeger - Readable Validation Rule
18
     *
19
     * Validates that a given input is a readable file or directory
20
     *
21
     * @package Validate\Rules\Filesystem
22
     * @author Eric Lamb <[email protected]>
23
     */
24
    class Readable extends AbstractRule
25
    {
26
27
        /**
28
         *
29
         * @ignore
30
         *
31
         * @var unknown
32
         */
33
        protected $name = 'readable';
34
35
        /**
36
         *
37
         * @ignore
38
         *
39
         * @var unknown
40
         */
41
        protected $error_message = '{field} has to be readable';
42
43
        /**
44
         * (non-PHPdoc)
45
         * 
46
         * @see \mithra62\Validate\RuleInterface::validate()
47
         * @ignore
48
         *
49
         */
50
        public function validate($field, $input, array $params = array())
51
        {
52
            if ($input instanceof \SplFileInfo) {
53
                return $input->isReadable();
54
            }
55
            
56
            return (is_string($input) && is_readable($input));
57
        }
58
    }
59
}