You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
>I am a **Citizen of the World**, and my Nationality is Goodwill.
19
19
20
-
<i>You can now read [a blog post](https://medium.com/@alex.olival/road-to-mastery-building-an-open-source-package-3936f57aed81) about how this package was created and its goals.</i>
21
-
22
20
**Socrates** is a PHP Package that allows you to validate and retrieve personal data from [National Identification Numbers](https://en.wikipedia.org/wiki/National_identification_number).
23
-
Most countries in Europe are supported as well as some American ones, but the goal is to eventually support as many countries in the world as possible.
21
+
Most countries in Europe are supported as well as some North and South American ones, with the goal to support as many countries in the world as possible.
24
22
<p>Some countries also encode personal information of the citizen, such as gender or the place of birth. This package allows you to extract that information in a consistent way.</p>
25
-
<p>A Facade and Validation Rule is also available for Laravel (see below).</p>
26
-
<p>This package can be useful for many things, such as validating a user's ID for finance related applications or verifying a user's age without asking for it explicitly. However, we recommend you review your country's data protection laws before storing any information.</p>
23
+
24
+
<p>This package can be useful for many things such as validating a user's ID for finance related applications or verifying a user's age without asking for it explicitly. We recommend you review your country's data processing and protection laws before storing any information.</p>
27
25
28
26
[Ports](https://github.com/reducktion/socrates#ports) of this package to other languages are currently in progress. Check further below for which ones are currently available.
29
27
30
28
## Installation
31
29
`composer require reducktion/socrates`
32
30
33
31
## Usage
34
-
Socrates provides two methods: `validateId` and `getCitizenDataFromId`. Both receive the ID and the country code in[ISO 3166-2 format](https://en.wikipedia.org/wiki/ISO_3166-2) as the first and second parameters respectively. Simply instantiate the class and call the method you wish:
32
+
Socrates provides two methods: `validateId` and `getCitizenDataFromId`. Both receive an ID and the country code as a backed enum with the[ISO 3166-2 format](https://en.wikipedia.org/wiki/ISO_3166-2) as the first and second parameters respectively. Simply instantiate the class and call the method you wish:
The `Citizen` class stores the extracted citizen data in a consistent format across all countries.<br>
86
-
It exposes the `getGender()`, `getDateOfBirthNative()`, `getDateOfBirth()`, `getAge()` and `getPlaceOfBirth()` methods.<br><br>
87
-
`getGender`and `getPlaceOfBirth`return a `string`.<br>
88
-
`getAge()` returns an `int`.<br>
89
-
`getDateOfBirthNative()` returns a native `DateTime` and `getDateOfBirth()` returns a `Carbon` instance.<br>
90
-
**It is recommended to use `getDateOfBirthNative()`as Carbon will be removed as a dependency in a future release of Socrates.**
64
+
It exposes the `getGender()`, `getDateOfBirth()`, `getAge()` and `getPlaceOfBirth()` methods.<br><br>
65
+
`getGender`will return an instance of the `Gender` enum.<br>
66
+
`getPlaceOfBirth` will return a city or region name as a `string`.<br>
67
+
`getAge()` returns the age of the citizen as an `int`.<br>
68
+
`getDateOfBirth()`returns a `DateTime` instance.<br>
91
69
<p>Using the example above, Estonia only encodes the date of birth and gender of the citizen in their ID. So the above methods will return:</p>
92
70
93
71
```php
94
-
echo $citizen->getGender(); // 'Male'
95
-
echo $citizen->getDateOfBirthNative(); // DateTime instance with the date '1986-01-23'
96
-
echo $citizen->getDateOfBirth(); // DEPRECATED - Carbon instance with the date '1986-01-23'
97
-
echo $citizen->getAge(); // 34
98
-
echo $citizen->getPlaceOfBirth(); // null
72
+
echo $citizen->getGender(); // 'Gender::Male'
73
+
echo $citizen->getDateOfBirth(); // DateTime instance with the date '1986-01-23'
74
+
echo $citizen->getAge(); // (The current age as a number)
75
+
echo $citizen->getPlaceOfBirth(); // null - Estonia does not encode place of birth on its ID numbers
99
76
```
100
77
101
78
## Supported and Unsupported Countries
102
79
103
80
[Here](COUNTRIES.md) you can see the full list of supported countries and whether they support data extraction.
104
81
105
82
Four european countries are currently unsupported: Austria 🇦🇹, Belarus 🇧🇾, Cyprus 🇨🇾 and Luxembourg 🇱🇺.
106
-
A number of countries in the Americas are also unsupproted. This is because we could not find a reliable source for the algorithm, if at all. Help would be appreciated to get these countries supported.
83
+
A number of countries in the Americas are also unsupported. This is because we could not find a reliable source for the algorithm, if at all. Help would be appreciated to get these countries supported.
107
84
108
85
## Testing
109
86
`composer test`
@@ -132,7 +109,7 @@ Socrates was made with 💖 by [Alexandre Olival](https://github.com/AlexOlival)
132
109
We are Reducktion.
133
110
We hope to make someone's life easier after all the hard work compiling, researching, reverse-engineering and agonizing over ID validation algorithms - many of which were very obscure and hard to find.
134
111
135
-
## Special thanks
112
+
## Special Thanks
136
113
A big thanks goes to these people who helped us either test with real life IDs or guide us in finding the algorithm for their countries:
0 commit comments