Completed
Pull Request — master (#6)
by Michał
01:47
created

NoteCollection   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 23
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A update() 0 4 1
A getUpdatedAt() 0 4 1
A find() 0 8 1
1
<?php
2
namespace Barenote\Collection;
3
4
use Barenote\Domain\Identity\NoteId;
5
use Barenote\Domain\Note;
6
7
/**
8
 * Class NoteCollection
9
 * @package Barenote\Collection
10
 * @method Note[] toArray()
11
 */
12
class NoteCollection extends ArrayCollection
13
{
14
    private $lastUpdated = null;
15
16
    public function update()
17
    {
18
        $this->lastUpdated = microtime(true);
19
    }
20
21
    public function getUpdatedAt()
22
    {
23
        return $this->lastUpdated;
24
    }
25
26
    public function find(NoteId $id)
27
    {
28
        return $this->filter(
29
            function (Note $note) use ($id) {
30
                return $note->getId() === $id;
31
            }
32
        );
33
    }
34
}