Completed
Push — master ( 69ca06...8af5d6 )
by Nate
03:36
created

RecordHelper::populate()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 16
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
dl 0
loc 16
c 0
b 0
f 0
ccs 0
cts 12
cp 0
rs 9.2
cc 4
eloc 7
nc 6
nop 3
crap 20
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://github.com/flipboxfactory/craft-ember/blob/master/LICENSE
6
 * @link       https://github.com/flipboxfactory/craft-ember
7
 */
8
9
namespace flipbox\ember\helpers;
10
11
use flipbox\ember\records\Record;
12
use yii\base\InvalidConfigException;
13
use yii\db\QueryInterface;
14
15
/**
16
 * @author Flipbox Factory <[email protected]>
17
 * @since 1.0.0
18
 */
19
class RecordHelper
20
{
21
    /**
22
     * @param $condition
23
     * @return array
24
     */
25
    public static function conditionToCriteria($condition)
26
    {
27
        if (empty($condition)) {
28
            return $condition;
29
        }
30
31
        // Assume it's an id
32
        if (!is_array($condition)) {
33
            $condition = [
34
                'id' => $condition
35
            ];
36
        }
37
38
        return ['where' => ['and', $condition]];
39
    }
40
}
41