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

TrCitizenNumberVerification   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 27
rs 10
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A verify() 0 22 5
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