Profiler::applyFilters()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 2
b 0
f 0
nc 2
nop 1
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 6
rs 10
1
<?php
2
3
namespace Nip\Database\Adapters\Profiler;
4
5
/**
6
 * Class Profiler
7
 * @package Nip\Database\Adapters\Profiler
8
 */
9
class Profiler extends \Nip_Profiler
10
{
11
    public $filterTypes = null;
12
13
    /**
14
     * @param $id
15
     * @return QueryProfile|\Nip\Profiler\Profile
16
     */
17
    public function newProfile($id)
18
    {
19
        return new QueryProfile($id);
20
    }
21
22
    /**
23
     * @param $profile
24
     * @return bool
25
     */
26
    protected function applyFilters($profile)
27
    {
28
        if (parent::applyFilters($profile)) {
29
            return $this->secondsFilter($profile);
30
        }
31
    }
32
33
    /**
34
     * @param $profile
35
     * @return bool
36
     */
37
    public function typeFilter($profile)
38
    {
39
        if (is_array($this->filterTypes) && in_array($profile->type, $this->filterTypes)) {
40
            $this->deleteProfile($profile);
41
42
            return false;
43
        }
44
45
        return true;
46
    }
47
48
    /**
49
     * @param null $queryTypes
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $queryTypes is correct as it would always require null to be passed?
Loading history...
50
     * @return $this
51
     */
52
    public function setFilterQueryType($queryTypes = null)
53
    {
54
        $this->filterTypes = $queryTypes;
55
56
        return $this;
57
    }
58
}
59