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

Answers   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 3
A getIterator() 0 3 1
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