PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.8.6
Kubio AI Page Builder v2.8.6
2.9.0 2.8.6 2.8.5 2.8.4 2.8.3 2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 2.0.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.5 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 2.6.5 2.6.6 2.6.7 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0
kubio / vendor / fzaninotto / faker / src / Faker / Calculator / TCNo.php
kubio / vendor / fzaninotto / faker / src / Faker / Calculator Last commit date
Ean.php 1 year ago Iban.php 1 year ago Inn.php 1 year ago Luhn.php 1 year ago TCNo.php 1 year ago
TCNo.php
53 lines
1 <?php
2
3 namespace Faker\Calculator;
4
5 use InvalidArgumentException;
6
7 class TCNo
8 {
9 /**
10 * Generates Turkish Identity Number Checksum
11 * Gets first 9 digit as prefix and calcuates checksums
12 *
13 * https://en.wikipedia.org/wiki/Turkish_Identification_Number
14 *
15 * @param string $identityPrefix
16 * @return string Checksum (two digit)
17 */
18 public static function checksum($identityPrefix)
19 {
20 if (strlen((string)$identityPrefix) !== 9) {
21 throw new InvalidArgumentException('Argument should be an integer and should be 9 digits.');
22 }
23
24 $oddSum = 0;
25 $evenSum = 0;
26
27 $identityArray = array_map('intval', str_split($identityPrefix)); // Creates array from int
28 foreach ($identityArray as $index => $digit) {
29 if ($index % 2 == 0) {
30 $evenSum += $digit;
31 } else {
32 $oddSum += $digit;
33 }
34 }
35
36 $tenthDigit = (7 * $evenSum - $oddSum) % 10;
37 $eleventhDigit = ($evenSum + $oddSum + $tenthDigit) % 10;
38
39 return $tenthDigit . $eleventhDigit;
40 }
41
42 /**
43 * Checks whether an TCNo has a valid checksum
44 *
45 * @param string $tcNo
46 * @return boolean
47 */
48 public static function isValid($tcNo)
49 {
50 return self::checksum(substr($tcNo, 0, -2)) === substr($tcNo, -2, 2);
51 }
52 }
53