MakeSearchable::resolve()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 6
1
<?php
2
/**
3
 * @link https://github.com/vuongxuongminh/yii2-searchable
4
 * @copyright Copyright (c) 2019 Vuong Xuong Minh
5
 * @license [New BSD License](http://www.opensource.org/licenses/bsd-license.php)
6
 */
7
8
namespace vxm\searchable\queue;
9
10
/**
11
 * Class MakeSearchable support make searchable index data via worker.
12
 *
13
 * @author Vuong Minh <[email protected]>
14
 * @since 1.0.0
15
 */
16
class MakeSearchable extends Job
17
{
18
19
    /**
20
     * @inheritDoc
21
     */
22
    protected function resolve(array $models): void
23
    {
24
        if (!empty($models)) {
25
26
            $modelClass = get_class(current($models));
27
            $modelClass::getSearchable()->upsert($models);
28
        }
29
    }
30
31
}
32