Completed
Pull Request — 2.0 (#1101)
by Rob
02:06
created

ControllerConfig::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
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
    /**
19
     * @var int
20
     */
21
    private $redirectResponseCode;
22
23
    /**
24
     * @param int $redirectResponseCode
25
     */
26
    public function __construct(int $redirectResponseCode)
27
    {
28
        if (!in_array($redirectResponseCode, [201, 301, 302, 303, 307, 308], true)) {
29
            throw new InvalidArgumentException(sprintf(
30
                'Invalid redirect response code "%s" (must be 201, 301, 302, 303, 307, or 308).', $redirectResponseCode
31
            ));
32
        }
33
34
        $this->redirectResponseCode = $redirectResponseCode;
35
    }
36
37
    /**
38
     * @return int
39
     */
40
    public function getRedirectResponseCode(): int
41
    {
42
        return $this->redirectResponseCode;
43
    }
44
}
45