Completed
Pull Request — master (#1220)
by
unknown
01:33
created

ControllerConfig::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
/*
4
 * This file is part of the `liip/LiipImagineBundle` project.
5
 *
6
 * (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
7
 *
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Liip\ImagineBundle\Config\Controller;
13
14
use Liip\ImagineBundle\Exception\InvalidArgumentException;
15
16
final class ControllerConfig
17
{
18
    private $redirectResponseCode;
19
20
    public function __construct(int $redirectResponseCode)
21
    {
22
        if (!in_array($redirectResponseCode, [201, 301, 302, 303, 307, 308], true)) {
23
            throw new InvalidArgumentException(sprintf(
24
                'Invalid redirect response code "%s" (must be 201, 301, 302, 303, 307, or 308).', $redirectResponseCode
25
            ));
26
        }
27
28
        $this->redirectResponseCode = $redirectResponseCode;
29
    }
30
31
    public function getRedirectResponseCode(): int
32
    {
33
        return $this->redirectResponseCode;
34
    }
35
}
36