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

InfoEntry   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
dl 0
loc 24
rs 10
c 1
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A get_detail() 0 8 3
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