Completed
Push — master ( bd08e0...27f167 )
by Ryan
05:48
created

MigrationRepository::getRan()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 1
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
1
<?php namespace Anomaly\Streams\Platform\Database\Migration;
2
3
use Illuminate\Database\Migrations\DatabaseMigrationRepository;
4
5
/**
6
 * Class MigrationRepository
7
 *
8
 * @link   http://pyrocms.com/
9
 * @author PyroCMS, Inc. <[email protected]>
10
 * @author Ryan Thompson <[email protected]>
11
 */
12
class MigrationRepository extends DatabaseMigrationRepository
13
{
14
15
    /**
16
     * The migrator instance.
17
     *
18
     * @var Migrator
19
     */
20
    protected $migrator = null;
21
22
    /**
23
     * Get ran migrations.
24
     *
25
     * @return array
26
     */
27
    public function getRan($namespace = null)
28
    {
29
        if ($addon = $this->migrator->getAddon()) {
30
            return $this->table()
31
                ->orderBy('batch', 'asc')
32
                ->orderBy('migration', 'asc')
33
                ->where('migration', 'LIKE', '%' . $addon->getNamespace() . '%')
34
                ->pluck('migration')->all();
35
        }
36
37
        return parent::getRan();
38
    }
39
40
    /**
41
     * Set the migrator.
42
     *
43
     * @param Migrator $migrator
44
     * @return $this
45
     */
46
    public function setMigrator(Migrator $migrator)
47
    {
48
        $this->migrator = $migrator;
49
50
        return $this;
51
    }
52
}
53