Api::isMobile()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 3
nc 4
nop 0
crap 3
1
<?php
2
3
namespace PayumTW\Ecpay;
4
5
use Exception;
6
use Detection\MobileDetect;
7
8
abstract class Api
9
{
10
    /**
11
     * $sdk.
12
     *
13
     * @var mixed
14
     */
15
    protected $sdk;
16
17
    /**
18
     * Verify if the hash of the given parameter is correct.
19
     *
20
     * @param array $params
21
     * @return bool
22
     */
23
    public function verifyHash(array $params)
24
    {
25
        $result = false;
26
        try {
27
            $this->sdk->CheckOutFeedback($params);
28
            $result = true;
29
        } catch (Exception $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
30
        }
31
32
        return $result;
33
    }
34
35
    /**
36
     * isMobile.
37
     *
38
     * @return bool
39
     */
40 2
    protected function isMobile()
41
    {
42 2
        $detect = new MobileDetect();
43
44 2
        return ($detect->isMobile() === false && $detect->isTablet() === false) ? false : true;
45
    }
46
}
47