FormatValidator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
c 1
b 0
f 0
dl 0
loc 13
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A valid() 0 9 2
1
<?php
2
3
namespace Conlect\ImageIIIF\Validators;
4
5
use Conlect\ImageIIIF\Exceptions\BadRequestException;
6
use Conlect\ImageIIIF\Validators\Contracts\ValidatorInterface;
7
8
class FormatValidator extends ValidatorAbstract implements ValidatorInterface
9
{
10
    use \Conlect\ImageIIIF\Traits\SupportedFormats;
11
12
    public function valid($format)
13
    {
14
        $formats = $this->getSupportedFormats($this->config['driver']);
15
16
        if (in_array($format, $formats)) {
17
            return true;
18
        }
19
20
        throw new BadRequestException("Format $format is invalid.");
21
    }
22
}
23