Completed
Pull Request — master (#6)
by Michał
04:52 queued 03:03
created

NoteCollection::getUpdatedAt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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