Test Failed
Push — master ( 2a75d8...e4b8e4 )
by Julien
12:49
created

FindIn::_findInParameters()   B

Complexity

Conditions 9
Paths 13

Size

Total Lines 42
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 90

Importance

Changes 0
Metric Value
eloc 24
c 0
b 0
f 0
dl 0
loc 42
ccs 0
cts 23
cp 0
rs 8.0555
cc 9
nc 13
nop 1
crap 90
1
<?php
2
3
/**
4
 * This file is part of the Zemit Framework.
5
 *
6
 * (c) Zemit Team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE.txt
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Zemit\Mvc\Model;
13
14
use Phalcon\Db\Column;
15
16
/**
17
 * @todo
18
 * - findIn
19
 * - FindInBy...
20
 * - findFirstIn
21
 * - findFirstInBy...
22
 */
23
trait FindIn
24
{
25
    public static function findInById(array $idList = [])
26
    {
27
        $castInt = function ($id) {
28
            return (int)$id;
29
        };
30
        
31
        $idList = array_unique(array_filter(array_map($castInt, $idList)));
32
        $idList = empty($idList) ? [null] : $idList;
33
        
34
        $bindParam = '_id' . uniqid('_', true) . '_';
35
        
36
        return self::find([
37
            '[id] = ({'.$bindParam.':array})',
38
            'bind' => [$bindParam => $idList],
39
            'bindTypes' => [$bindParam => Column::BIND_PARAM_INT]
40
        ]);
41
    }
42
}
43