Completed
Push — master ( d1902c...e3e6b5 )
by WEBEWEB
01:26
created

DataTablesEntityHelper::isCompatible()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
c 0
b 0
f 0
rs 9.8666
cc 4
nc 3
nop 1
1
<?php
2
3
/*
4
 * This file is part of the jquery-datatables-bundle package.
5
 *
6
 * (c) 2019 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\JQuery\DataTablesBundle\Helper;
13
14
use WBW\Bundle\JQuery\DataTablesBundle\Entity\DataTablesEntityInterface;
15
16
/**
17
 * DataTables entity helper.
18
 *
19
 * @author webeweb <https://github.com/webeweb/>
20
 * @package WBW\Bundle\JQuery\DataTablesBundle\Helper
21
 */
22
class DataTablesEntityHelper {
23
24
    /**
25
     * Determines if an entity is compatible.
26
     *
27
     * @param DataTablesEntityInterface|object $entity The entity.
28
     * @return bool Returns true in case of success, false otherwise.
29
     */
30
    public static function isCompatible($entity) {
31
32
        if (true === ($entity instanceof DataTablesEntityInterface)) {
33
            return true;
34
        }
35
36
        if (true === is_object($entity) && true === method_exists($entity, "getId")) {
37
            return true;
38
        }
39
40
        return false;
41
    }
42
}
43