Completed
Push — master ( 30a2b5...89612e )
by Axel
02:59
created

TrelloRegistry::hasBoard()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Scrumban\Registry;
4
5
use Scrumban\Entity\UserStory;
6
7
final class TrelloRegistry implements RegistryInterface
8
{
9
    /** @var array **/
10
    private $boards;
11
    /** @var array **/
12
    private $columns;
13
    /** @var array **/
14
    private $userStories;
15
    
16
    public function __construct(array $boards, array $columns)
17
    {
18
        $this->boards = $boards;
19
        $this->columns = $columns;
20
    }
21
    
22
    public function getBoard(string $name): ?array
23
    {
24
        return $this->boards[$name] ?? null;
25
    }
26
    
27
    public function getColumn(string $name): ?array
28
    {
29
        foreach ($this->columns as $column) {
30
            if ($column['name'] === $name) {
31
                return $column;
32
            }
33
        }
34
        return null;
35
    }
36
    
37
    public function storeUserStories(array $userStories = [])
38
    {
39
        foreach ($userStories as $userStory) {
40
            $this->userStories[$userStory->getId()] = $userStory;
41
        }
42
    }
43
    
44
    public function getUserStory(string $id): ?UserStory
45
    {
46
        return $this->userStories[$id] ?? null;
47
    }
48
}
49