Skip to content

Commit

Permalink
Ultimile modificari
Browse files Browse the repository at this point in the history
  • Loading branch information
filipac committed Mar 2, 2015
1 parent f0c983b commit e239f4e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,37 @@
## Filipac CNP - Validare CNP
[![Build Status](https://travis-ci.org/filipac/cnp.svg)](https://travis-ci.org/laravel/framework)[![Latest Stable Version](https://poser.pugx.org/filipac/cnp/v/stable.svg)](https://packagist.org/packages/filipac/cnp) [![Total Downloads](https://poser.pugx.org/filipac/cnp/downloads.svg)](https://packagist.org/packages/filipac/cnp) [![Latest Unstable Version](https://poser.pugx.org/filipac/cnp/v/unstable.svg)](https://packagist.org/packages/filipac/cnp) [![License](https://poser.pugx.org/filipac/cnp/license.svg)](https://packagist.org/packages/filipac/cnp)

### Cum instalez pachetul?
```
composer require filipac/cnp ~1.0
```
Sau introduceti in sectiunea require din ```composer.json```:
```json
"filipac/cnp": "~1.0"
```

### Cum folosesc acest pachet?
Clasa ```Cnp``` are 2 metode publice statice: ```valid``` care returneaza un boolean (true, false). Este disponibila si functia
```invalid``` care este practic functia valid, dar negata.
```php
<?php
use Filipac\Cnp\Cnp;
if(Cnp::valid('1930101021162')) #true
echo 'Cnp-ul este valid';
if(! Cnp::valid('1930101021161')) #false
echo 'Cnp-ul este invalid';
if(Cnp::invalid('1930101021161')) #true
echo 'Cnp-ul este invalid';
if(!Cnp::invalid('1930101021162')) #false
echo 'Cnp-ul este valid';
?>
```

### Cum sa contribui?
Daca ai idei de imbunatatire a acestui script, da fork acestui repository, fa modificarile necesare si apoi da un pull-request.
Nu uita sa scrii un test (vezi ```tests/CnpTest.php```) pentru ce ai implementat, altfel nu voi accepta request-ul.
Testarea se face cu **PhpUnit**.

### Licienta

This comment has been minimized.

Copy link
@andreifilip123

andreifilip123 May 5, 2018

Licenta*
Mulțumesc frumos de script 👍


Acest script este distribuit sub [licienta MIT](http://opensource.org/licenses/MIT).
6 changes: 6 additions & 0 deletions src/Cnp.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
class Cnp
{

public static function invalid($cnp)
{
return ! static::valid($cnp);
}


public static function valid($p_cnp)
{
// CNP must have 13 characters
Expand Down
10 changes: 8 additions & 2 deletions tests/CnpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,20 @@ public function testCnpValid()
{
$valid = Cnp::valid('1930101021162');
$this->assertTrue($valid);

$valid = Cnp::invalid('1930101021162');
$this->assertFalse($valid);
}


/** @test */
public function testCnpInvalid()
{
$valid = Cnp::valid('1930101021161');
$this->assertFalse($valid);
$invalid = Cnp::valid('1930101021161');
$this->assertFalse($invalid);

$invalid = Cnp::invalid('1930101021161');
$this->assertTrue($invalid);
}

}

0 comments on commit e239f4e

Please # to comment.