FormatValidator::valid()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 9
rs 10
cc 2
nc 2
nop 1
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