Passed
Push — feature/VSVGVQ-7 ( b7fce3...c163e5 )
by steven
03:10
created

Answers::__construct()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 3
nc 2
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace VSV\GVQ_API\Question;
4
5
class Answers implements \IteratorAggregate
6
{
7
    /**
8
     * @var Answer[]
9
     */
10
    private $answers;
11
12
    /**
13
     * @param Answer ...$answers
14
     */
15
    public function __construct(Answer ...$answers)
16
    {
17
        if (count($answers) <= 1 || count($answers) >= 4) {
18
            throw new \InvalidArgumentException('Amount of answers must be 2 or 3.');
19
        }
20
        $this->answers = $answers;
21
    }
22
23
    /**
24
     * @inheritdoc
25
     */
26
    public function getIterator()
27
    {
28
        return new \ArrayIterator($this->answers);
29
    }
30
}
31