ImportStages::fromSource()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 11
ccs 9
cts 9
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Matchish\ScoutElasticSearch\Jobs;
4
5
use Illuminate\Support\Collection;
6
use Matchish\ScoutElasticSearch\ElasticSearch\Index;
7
use Matchish\ScoutElasticSearch\Jobs\Stages\CleanUp;
8
use Matchish\ScoutElasticSearch\Jobs\Stages\CreateWriteIndex;
9
use Matchish\ScoutElasticSearch\Jobs\Stages\PullFromSource;
10
use Matchish\ScoutElasticSearch\Jobs\Stages\RefreshIndex;
11
use Matchish\ScoutElasticSearch\Jobs\Stages\SwitchToNewAndRemoveOldIndex;
12
use Matchish\ScoutElasticSearch\Searchable\ImportSource;
13
14
class ImportStages extends Collection
15
{
16
    /**
17
     * @param ImportSource $source
18
     * @return Collection
19
     */
20 15
    public static function fromSource(ImportSource $source)
21
    {
22 15
        $index = Index::fromSource($source);
23
24 15
        return (new self([
25 15
            new CleanUp($source),
26 15
            new CreateWriteIndex($source, $index),
27 15
            PullFromSource::chunked($source),
28 15
            new RefreshIndex($index),
29 15
            new SwitchToNewAndRemoveOldIndex($source, $index),
30 15
        ]))->flatten()->filter();
31
    }
32
}
33