Completed
Push — master ( 01798b...15f6ef )
by Anton
08:29
created

Writable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 7 3
1
<?php
2
/**
3
 * @copyright Bluz PHP Team
4
 * @link https://github.com/bluzphp/bluzman
5
 */
6
7
namespace Bluzman\Validator\Rule;
8
9
use Bluz\Validator\Rule\AbstractRule;
10
11
/**
12
 * @package Bluzman\Validation\Rules
13
 */
14
class Writable extends AbstractRule
15
{
16
    /**
17
     * @var string error template
18
     */
19
    protected $template = '{{name}} must be writable';
20
21
    /**
22
     * @param mixed $input
23
     * @return bool
24
     */
25
    public function validate($input) : bool
26
    {
27
        if ($input instanceof \SplFileInfo) {
28
            return $input->isWritable();
29
        }
30
        return is_string($input) && is_writable($input);
31
    }
32
}
33