CronMonthFormatValidator::validateTimeEntry()   B
last analyzed

Complexity

Conditions 7
Paths 4

Size

Total Lines 16
Code Lines 8

Duplication

Lines 16
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 16
loc 16
rs 8.2222
cc 7
eloc 8
nc 4
nop 1
1
<?php
2
3
namespace FOA\CronBundle\Validator\Constraints;
4
5
/**
6
 * @author JM Leroux <[email protected]>
7
 */
8 View Code Duplication
class CronMonthFormatValidator extends AbstractCronTimeFormatValidator
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /**
11
     * @inheritdoc
12
     */
13
    protected function validateTimeEntry($item)
14
    {
15
        if ('' === trim($item)) {
16
            return false;
17
        }
18
19
        if (is_numeric($item) && ($item < 1 || $item > 12)) {
20
            return false;
21
        }
22
23
        if (!is_numeric($item) && !preg_match('#(^\*$)|(^\*/[0-9]+$)#', $item)) {
24
            return false;
25
        }
26
27
        return true;
28
    }
29
}
30