Skip to content

Commit

Permalink
package release
Browse files Browse the repository at this point in the history
  • Loading branch information
makowskid committed Dec 1, 2023
1 parent 0f4c907 commit 955c601
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 292 deletions.
18 changes: 0 additions & 18 deletions .codecov.yml

This file was deleted.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Please be considerate towards maintainers when raising issues or presenting pull
world that developers are civilized and selfless people.

It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
quality to benefit the project. Many developers have different skills, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.

## Viability

Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) Makowskid<mailto:dawid.makowski@gmail.com>
Copyright (c) Dawid Makowski <mailto:dawid.makowski@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
15 changes: 2 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# sg-nric

Singapore NRIC (National Registration Identity Card) or FIN (Foreign Identification Number) validator package
PHP Singapore NRIC (National Registration Identity Card) or FIN (Foreign Identification Number) validator package


[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
Expand All @@ -17,28 +17,17 @@ composer require makowskid/sg-nric
## Usage

```bash
$validator = new \makowskid\SgNric\SgNricValidator();
$validator = new \Makowskid\SgNric\SgNric();

if($validator->isNricValid($theNric)) ..

//or


if($validatator->isFinValid($theNric)) ..

// or use the defined `sg-nric` facade

```

## Testing

Run the tests with:

```bash
vendor/bin/phpunit
```


## Contributing

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
Expand Down
98 changes: 43 additions & 55 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,58 +1,46 @@
{
"name": "makowskid/sg-nric",
"description": "Package to easily validate Singapore NRIC/FIN numbers",
"type": "library",
"license": "MIT",
"keywords": [
"nric",
"fin",
"singapore",
"validator"
],
"authors": [
{
"name": "Dawid Makowski",
"email": "dawid.makowski@gmail.com"
}
],
"minimum-stability": "dev",
"prefer-stable":true,
"require": {},
"require-dev": {
"symfony/thanks": "^1.0",
"phpunit/phpunit": "^7.4@dev",
"mockery/mockery": "^1.0@dev",
"orchestra/testbench": "^3.8@dev",
"orchestra/database": "^3.8@dev",
"illuminate/support": "^5.8@dev",
"fzaninotto/faker": "^1.9@dev"
},
"autoload": {
"psr-4": {
"Makowskid\\SgNric\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Makowskid\\SgNric\\Tests\\":"tests/"
}
},
"config": {
"preferred-install": "dist",
"sort-packages": true
},
"scripts": {
"test": "vendor/bin/phpunit",
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
},
"extra": {
"laravel": {
"providers": [
"Makowskid\\SgNric\\SgNricServiceProvider"
],
"aliases": {
"Makowskid": "Makowskid\\SgNric\\SgNricFacade"
}
}
"name": "makowskid/sg-nric",
"description": "Package to easily validate Singapore NRIC/FIN numbers in PHP",
"type": "library",
"license": "MIT",
"keywords": [
"nric",
"fin",
"singapore",
"validator"
],
"authors": [
{
"name": "Dawid Makowski",
"email": "dawid.makowski@gmail.com"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"require": {},
"require-dev": {
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {
"Makowskid\\SgNric\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Makowskid\\SgNric\\Tests\\": "tests/"
}
},
"config": {
"preferred-install": "dist",
"sort-packages": true
},
"scripts": {
"test": "vendor/bin/phpunit",
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
},
"support": {
"issues": "https://github.com/makowskid/sg-nric/issues",
"source": "https://github.com/makowskid/sg-nric"
}
}
33 changes: 0 additions & 33 deletions phpunit.xml

This file was deleted.

21 changes: 5 additions & 16 deletions src/SgNric.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
<?php

namespace makowskid\SgNric;
namespace Makowskid\SgNric;

/**
* Class SgNricValidator
* @package makowskid\SgNric
* @author Dawid Makowski <dawid.makowski@gmail.com>
* @author Marshall Jones <marshall@offby3.com> https://github.com/mjallday
*/
class SgNricValidator
class SgNric
{

/**
* SgNricValidator constructor.
*/
public function __construct()
{
}

/**
* @param $theNric
* @return bool
*/
public function isNricValid($theNric)
public function isNricValid($theNric): bool
{

$multiples = array(2, 7, 6, 5, 4, 3, 2);
Expand All @@ -37,7 +31,6 @@ public function isNricValid($theNric)

$total = 0;
$count = 0;
$numericNric = 0;

$first = $theNric[0];
$last = $theNric[strlen($theNric) - 1];
Expand All @@ -59,11 +52,10 @@ public function isNricValid($theNric)
$numericNric = floor($numericNric);
}

$outputs = '';
if (strcmp($first, "S") == 0) {
$outputs = ['J', 'Z', 'I', 'H', 'G', 'F', 'E', 'D', 'C', 'B', 'A'];
} else {
$outputs = array['G', 'F', 'E', 'D', 'C', 'B', 'A', 'J', 'Z', 'I', 'H'];
$outputs = ['G', 'F', 'E', 'D', 'C', 'B', 'A', 'J', 'Z', 'I', 'H'];
}

return $last == $outputs[$total % 11];
Expand All @@ -74,7 +66,7 @@ public function isNricValid($theNric)
* @param $fin
* @return bool
*/
public function isFinValid($fin)
public function isFinValid($fin): bool
{
$multiples = [2, 7, 6, 5, 4, 3, 2];
if (!$fin || $fin == '') {
Expand All @@ -87,7 +79,6 @@ public function isFinValid($fin)

$total = 0;
$count = 0;
$numericNric = 0;
$first = $fin[0];
$last = $fin[strlen($fin) - 1];

Expand All @@ -108,8 +99,6 @@ public function isFinValid($fin)
$numericNric = floor($numericNric);
}

$outputs = array();

if (strcmp($first, 'F') == 0) {
$outputs = ['X', 'W', 'U', 'T', 'R', 'Q', 'P', 'N', 'M', 'L', 'K'];
} else {
Expand Down
18 changes: 0 additions & 18 deletions src/SgNricFacade.php

This file was deleted.

61 changes: 0 additions & 61 deletions src/SgNricServiceProvider.php

This file was deleted.

20 changes: 0 additions & 20 deletions tests/Feature/ExampleTest.php

This file was deleted.

Loading

0 comments on commit 955c601

Please sign in to comment.