From 955c601993ecd05ead0407ea35a2c3def79c3dbe Mon Sep 17 00:00:00 2001 From: Dawid Makowski Date: Fri, 1 Dec 2023 12:15:19 +0700 Subject: [PATCH] package release --- .codecov.yml | 18 ------- CONTRIBUTING.md | 2 +- LICENSE.md | 2 +- README.md | 15 +----- composer.json | 98 +++++++++++++++-------------------- phpunit.xml | 33 ------------ src/SgNric.php | 21 ++------ src/SgNricFacade.php | 18 ------- src/SgNricServiceProvider.php | 61 ---------------------- tests/Feature/ExampleTest.php | 20 ------- tests/TestCase.php | 37 ------------- tests/Unit/ExampleTest.php | 19 ------- 12 files changed, 52 insertions(+), 292 deletions(-) delete mode 100644 .codecov.yml delete mode 100644 phpunit.xml delete mode 100644 src/SgNricFacade.php delete mode 100644 src/SgNricServiceProvider.php delete mode 100644 tests/Feature/ExampleTest.php delete mode 100644 tests/TestCase.php delete mode 100644 tests/Unit/ExampleTest.php diff --git a/.codecov.yml b/.codecov.yml deleted file mode 100644 index 8a9bf31..0000000 --- a/.codecov.yml +++ /dev/null @@ -1,18 +0,0 @@ -codecov: - notify: - require_ci_to_pass: yes - -coverage: - precision: 2 - round: down - range: “70…100” - -status: - project: yes - patch: yes - changes: no - -comment: - layout: "reach, diff, flags, files, footer" - behavior: default - require_changes: no diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6d6a8e5..4a3c0b7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 diff --git a/LICENSE.md b/LICENSE.md index 74b0745..beb295d 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) Makowskid +Copyright (c) Dawid Makowski Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index e89f757..f43590a 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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. diff --git a/composer.json b/composer.json index f8ac2e9..8e50c1a 100644 --- a/composer.json +++ b/composer.json @@ -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" + } } diff --git a/phpunit.xml b/phpunit.xml deleted file mode 100644 index 8ec4a81..0000000 --- a/phpunit.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - tests - - - - - src/ - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/SgNric.php b/src/SgNric.php index 4d30280..e3ab5c6 100644 --- a/src/SgNric.php +++ b/src/SgNric.php @@ -1,6 +1,6 @@ * @author Marshall Jones 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); @@ -37,7 +31,6 @@ public function isNricValid($theNric) $total = 0; $count = 0; - $numericNric = 0; $first = $theNric[0]; $last = $theNric[strlen($theNric) - 1]; @@ -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]; @@ -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 == '') { @@ -87,7 +79,6 @@ public function isFinValid($fin) $total = 0; $count = 0; - $numericNric = 0; $first = $fin[0]; $last = $fin[strlen($fin) - 1]; @@ -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 { diff --git a/src/SgNricFacade.php b/src/SgNricFacade.php deleted file mode 100644 index 3a48ead..0000000 --- a/src/SgNricFacade.php +++ /dev/null @@ -1,18 +0,0 @@ -loadViewsFrom(__DIR__.'/resources/views', 'sg-nric'); - // $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); - // $this->registerRoutes(); - } - - /** - * Register the package routes. - * - * @return void - */ - private function registerRoutes() - { - Route::group($this->routeConfiguration(), function () { - $this->loadRoutesFrom(__DIR__ . '/Http/routes.php'); - }); - } - - /** - * Get route group configuration array. - * - * @return array - */ - private function routeConfiguration() - { - return [ - 'namespace' => "Makowskid\SgNric\Http\Controllers", - 'middleware' => 'api', - 'prefix' => 'api' - ]; - } - - /** - * Register any application services. - * - * @return void - */ - public function register() - { - // Register facade - $this->app->singleton('sg-nric', function () { - return new SgNric; - }); - } - -} diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php deleted file mode 100644 index 13ae53c..0000000 --- a/tests/Feature/ExampleTest.php +++ /dev/null @@ -1,20 +0,0 @@ -get('/'); - - $response->assertStatus(200); - } -} diff --git a/tests/TestCase.php b/tests/TestCase.php deleted file mode 100644 index 12ca56d..0000000 --- a/tests/TestCase.php +++ /dev/null @@ -1,37 +0,0 @@ -withoutExceptionHandling(); - $this->artisan('migrate', ['--database' => 'testing']); - - $this->loadMigrationsFrom(__DIR__ . '/../src/database/migrations'); - $this->loadLaravelMigrations(['--database' => 'testing']); - - $this->withFactories(__DIR__.'/../src/database/factories'); - } - - protected function getEnvironmentSetUp($app) - { - $app['config']->set('app.key', 'AckfSECXIvnK5r28GVIWUAxmbBSjTsmF'); - $app['config']->set('database.default', 'testing'); - $app['config']->set('database.connections.testing', [ - 'driver' => 'sqlite', - 'database' => ':memory:', - 'prefix' => '', - ]); - } - - protected function getPackageProviders($app) - { - return [SgNricServiceProvider::class]; - } -} diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php deleted file mode 100644 index c3bf688..0000000 --- a/tests/Unit/ExampleTest.php +++ /dev/null @@ -1,19 +0,0 @@ -assertTrue(true); - } -}