TrCitizenNumberVerification   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A verify() 0 22 5
1
<?php
2
3
namespace XAdam;
4
5
class TrCitizenNumberVerification
6
{
7
    public const API_URL = 'https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?WSDL';
8
    private static ?object $client = null;
9
10
    public static function verify(int $citizen_number, int $birth_year, string $name, string $surname): bool
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([
0 ignored issues
show
Bug introduced by
The method TCKimlikNoDogrula() does not exist on null. ( Ignorable by Annotation )

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

24
        /** @scrutinizer ignore-call */ 
25
        $response = static::$client->TCKimlikNoDogrula([

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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