Passed
Pull Request — master (#1856)
by
unknown
04:46
created

Detail::sub_details()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 16
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 7
c 1
b 0
f 0
nc 4
nop 0
dl 0
loc 16
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MySociety\TheyWorkForYou\DataClass\Regmem;
6
7
use MySociety\TheyWorkForYou\DataClass\BaseModel;
8
9
class Detail {
10
    public string $source;
11
    public ?string $slug = null;
12
    public ?string $display_as = null;
13
    public ?string $common_key = null;
14
    public ?string $description = null;
15
    public ?string $type = null;
16
    public $value = null;
17
    public AnnotationList $annotations;
18
19
    /**
20
     * @return \Iterator<Detail>|
21
     */
22
    public function sub_details(): \Iterator {
23
24
25
        $items = new \ArrayIterator();
26
27
        if (!$this->value instanceof DetailGroup) {
28
            return $items;
29
        }
30
31
        foreach ($this->value as $detail_group) {
32
            foreach ($detail_group as $detail) {
33
                $items[] = $detail;
34
            }
35
        }
36
37
        return $items;
38
    }
39
40
}
41