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

NoteCollection::find()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 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
}