Passed
Push — master ( 1e77ab...d0f64e )
by Matthew
06:39
created

InfoEntry::get_detail()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 3
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
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 InfoEntry extends BaseModel {
10
    public ?string $id = null;
11
    public ?string $comparable_id = null;
12
    public string $item_hash;
13
    public string $content;
14
    public string $content_format;
15
    public string $info_type;
16
    public bool $null_entry;
17
    public ?string $date_registered = null;
18
    public ?string $date_published = null;
19
    public ?string $date_updated = null;
20
    public ?string $date_received = null;
21
    public AnnotationList $annotations;
22
    public DetailGroup $details;
23
    public EntryList $sub_entries;
24
25
    public function get_detail(string $slug): ?Detail {
26
        // given a slug, return the detail object
27
        foreach ($this->details as $detail) {
28
            if ($detail->slug === $slug) {
29
                return $detail;
30
            }
31
        }
32
        return null;
33
    }
34
35
}
36