OtpBuildTrait   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 81.82%

Importance

Changes 0
Metric Value
dl 0
loc 39
ccs 9
cts 11
cp 0.8182
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A checkMobile() 0 3 1
A checkAuthKey() 0 3 1
A isParameterPresent() 0 11 3
1
<?php
2
namespace Sender\Traits;
3
4
use Sender\Validation;
5
use Sender\MobileNumber;
6
use Sender\Otp\OtpBuildClass;
7
use Sender\Otp\OtpDefineClass;
8
use Sender\ExceptionClass\ParameterException;
9
10
/**
11
 * This trait for OTP FUNCTIONS
12
 *
13
 * @package    Msg91 SMS&OTP package
14
 * @author     VenkatS <[email protected]>
15
 * @link       https://github.com/tesark/msg91-php
16
 * @license    MIT
17
 */
18
19
trait OtpBuildTrait
20
{
21
    /**
22
     * Check Authkey and mobile
23
     * @param string $parameter
24
     *
25
     * @throws ParameterException missing parameters or return empty
26
     * @return bool
27
     */
28 20
    public function isParameterPresent($parameter)
29
    {
30 20
        if ($this->isKeyExists($parameter, $this->sendData)) {
0 ignored issues
show
Bug Best Practice introduced by
The property sendData does not exist on Sender\Traits\OtpBuildTrait. Did you maybe forget to declare it?
Loading history...
Bug introduced by
It seems like isKeyExists() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
        if ($this->/** @scrutinizer ignore-call */ isKeyExists($parameter, $this->sendData)) {
Loading history...
31 20
            if ($parameter === 'authkey') {
32 20
                return $this->hasAuthKey($parameter);
0 ignored issues
show
Bug introduced by
It seems like hasAuthKey() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
                return $this->/** @scrutinizer ignore-call */ hasAuthKey($parameter);
Loading history...
33
            } else {
34 20
                return $this->hasMobile($parameter);
0 ignored issues
show
Bug introduced by
It seems like hasMobile() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
                return $this->/** @scrutinizer ignore-call */ hasMobile($parameter);
Loading history...
35
            }
36
        } else {
37
            $message = "Parameter ".$parameter." missing";
38
            throw ParameterException::missinglogic($message);
39
        }
40
    }
41
    /**
42
     * Check Authkey
43
     *
44
     * @return bool
45
     */
46 20
    public function checkAuthKey()
47
    {
48 20
        return $this->isParameterPresent('authkey');
49
    }
50
    /**
51
     * Check mobile
52
     *
53
     * @return bool
54
     */
55 20
    public function checkMobile()
56
    {
57 20
        return $this->isParameterPresent('mobile');
58
    }
59
}
60