MigrationRepositoryImpl::findOneByName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * File was created 05.07.2016 17:06
4
 */
5
6
namespace PeekAndPoke\Component\Slumber\Data\Migration;
7
8
use PeekAndPoke\Component\Slumber\Data\Cursor;
9
use PeekAndPoke\Component\Slumber\Data\EntityRepository;
10
use PeekAndPoke\Component\Slumber\Data\Migration\DomainModel\ExecutedMigration;
11
12
13
/**
14
 * @method ExecutedMigration[]|Cursor find(array $query = null)
15
 * @method ExecutedMigration|null     findOne(array $query = null)
16
 * @method ExecutedMigration|null     findById($id)
17
 * @method ExecutedMigration|null     findByReference($reference)
18
 *
19
 * @author Karsten J. Gerber <[email protected]>
20
 */
21
class MigrationRepositoryImpl extends EntityRepository implements MigrationRepository
22
{
23
    /**
24
     * @return ExecutedMigration[]|Cursor
25
     */
26
    public function findAll()
27
    {
28
        return $this->find()->sort(['_id' => 1]);
29
    }
30
31
    /**
32
     * @param string $name
33
     *
34
     * @return ExecutedMigration|Cursor
35
     */
36
    public function findOneByName($name)
37
    {
38
        return $this->findOne([
39
            'name' => $name,
40
        ]);
41
    }
42
43
    /**
44
     * @param string $name
45
     *
46
     * @return int
47
     */
48
    public function countByName($name)
49
    {
50
        return $this->find([
51
            'name' => $name,
52
        ])->count();
53
    }
54
55
    /**
56
     * @param ExecutedMigration $executedMigration
57
     */
58
    public function store(ExecutedMigration $executedMigration)
59
    {
60
        $this->save($executedMigration);
61
    }
62
63
    /**
64
     * @param ExecutedMigration $executedMigration
65
     */
66
    public function delete(ExecutedMigration $executedMigration)
67
    {
68
        $this->remove($executedMigration);
69
    }
70
}
71