Passed
Push — master ( 8baa4a...fa5dd9 )
by João Felipe Magro
01:17
created

SubscriptionValidator::isValidProfileId()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 2
eloc 1
nc 2
nop 1
1
<?php
2
3
namespace Ipag\Classes\Validators;
4
5
use Ipag\Classes\Enum\Interval;
6
7
final class SubscriptionValidator
8
{
9
    public function isValidFrequency($frequency)
10
    {
11
        return (bool) (is_numeric($frequency) && strlen($frequency) >= 1 && strlen($frequency) <= 2);
12
    }
13
14
    public function isValidInterval($interval)
15
    {
16
        switch ($interval) {
17
            case Interval::DAY:
18
            case Interval::WEEK:
19
            case Interval::MONTH:
20
                return true;
21
            default:
22
                return false;
23
        }
24
    }
25
26
    public function isValidCycle($cycle)
27
    {
28
        return (bool) (is_numeric($cycle) && strlen($cycle) >= 1 && strlen($cycle) <= 3);
29
    }
30
31
    public function isValidProfileId($profileId)
32
    {
33
        return (bool) (is_numeric($profileId) && strlen($profileId) <= 32);
34
    }
35
}
36