Passed
Push — master ( 72e097...a8de4e )
by Mehmet
07:02
created

TrCitizenNumberVerification::verify()   A

Complexity

Conditions 5
Paths 4

Size

Total Lines 22
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 12
c 1
b 0
f 0
nc 4
nop 4
dl 0
loc 22
rs 9.5555
1
<?php
2
3
namespace XAdam;
4
5
class TrCitizenNumberVerification
6
{
7
    const API_URL = 'https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?WSDL';
8
    private static $client = null;
9
10
    public static function verify($citizen_number, $birth_year, $name, $surname)
11
    {
12
        if (!TrCitizenNumberValidation::validate($citizen_number)) {
13
            return false;
14
        }
15
16
        if ($birth_year < 1900 || $birth_year > date('Y')) {
17
            return false;
18
        }
19
20
        if (static::$client === null) {
0 ignored issues
show
Bug introduced by
Since $client is declared private, accessing it with static will lead to errors in possible sub-classes; you can either use self, or increase the visibility of $client to at least protected.
Loading history...
21
            static::$client = new \SoapClient(static::API_URL);
22
        }
23
24
        $response = static::$client->TCKimlikNoDogrula(array(
25
            'TCKimlikNo' => $citizen_number,
26
            'Ad' => tr_strtoupper($name),
27
            'Soyad' => tr_strtoupper($surname),
28
            'DogumYili' => $birth_year
29
        ));
30
31
        return $response->TCKimlikNoDogrulaResult;
32
    }
33
}
34