Skip to content

Commit

Permalink
update docs and add is function
Browse files Browse the repository at this point in the history
  • Loading branch information
fatkulnurk committed Jan 26, 2020
1 parent 04cb07d commit e3b8dde
Show file tree
Hide file tree
Showing 16 changed files with 736 additions and 30 deletions.
7 changes: 6 additions & 1 deletion .idea/is-thirteen.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 26 additions & 4 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 45 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,58 @@
# Is Thirteen
An PHP package to check if a number is equal to 13.
An PHP package to check if a number is equal to 13. Ispirate by jezen/is-thirteen library.

### Installation
````
composer require fatkulnurk/is-thirteen
````

### Usage
In use, we provide several options. first option using objects from class Is and the second option using the is () function which can be called globally.

````
<?php
use Fatkulnurk\IsThirteen\Is;
var_dump((new Is(13))->thirteen()); //true
echo "\r\n";
var_dump((new Is(12.8))->roughly()->thirteen()); // true
echo "\r\n";
var_dump((new Is(6))->within(10)->of()->thirteen()); // true
echo "\r\n";
var_dump((new Is(2007))->yearOfBirth()); // true
echo "\r\n";
// now with elegant syntax.
echo (new Is(13))->thirteen(); //true
echo (new Is(12.8))->roughly()->thirteen(); // true
echo (new Is(6))->within(10)->of()->thirteen(); // true
echo (new Is(2007))->yearOfBirth(); // true
echo "Math";
echo "\r\n";
var_dump((new Is(4))->plus(5)->thirteen()); // false
echo "\r\n";
var_dump((new Is(12))->plus(1)->thirteen()); // true
echo "\r\n";
var_dump((new Is(4))->minus(12)->thirteen()); // false
echo "\r\n";
var_dump((new Is(14))->minus(1)->thirteen()); // true
echo "\r\n";
var_dump((new Is(1))->times(8)->thirteen()); // false
echo "\r\n";
var_dump((new Is(26))->divideby(2)->thirteen()); // true
echo "\r\n";
````
echo (new Is(4))->plus(5)->thirteen(); // false
echo (new Is(12))->plus(1)->thirteen(); // true
echo (new Is(4))->minus(12)->thirteen(); // false
echo (new Is(14))->minus(1)->thirteen(); // true
echo (new Is(1))->times(8)->thirteen(); // false
echo (new Is(26))->divideby(2)->thirteen(); // true
````


### Example

is-thirteen with (new) :
````
<?php
include "vendor/autoload.php";
use Fatkulnurk\IsThirteen\Is;
if((new Is(13))->thirteen()) {
echo "is thirteen";
}
````

is-thirteen with helper function :
````
<?php
include "vendor/autoload.php";
use Fatkulnurk\IsThirteen\Is;
if(is(13))->thirteen()) {
echo "is thirteen";
}
````

---
Created by fatkulnurk@gmail.com
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
"autoload": {
"psr-4": {
"Fatkulnurk\\IsThirteen\\": "src/"
}
},
"files": [
"src/functions.php"
]
},
"require": {}
}
27 changes: 26 additions & 1 deletion example.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
use Fatkulnurk\IsThirteen\Is;
include "vendor/autoload.php";

use Fatkulnurk\IsThirteen\Is;
echo "Create with new : <br>";
var_dump((new Is(13))->thirteen());
echo "\r\n";
var_dump((new Is(12.8))->roughly()->thirteen());
Expand All @@ -22,4 +24,27 @@
var_dump((new Is(1))->times(8)->thirteen());
echo "\r\n";
var_dump((new Is(26))->divideby(2)->thirteen());
echo "\r\n";
echo "Create from is Function: <br>";
var_dump((is(13))->thirteen());
echo "\r\n";
var_dump((is(12.8))->roughly()->thirteen());
echo "\r\n";
var_dump((is(6))->within(10)->of()->thirteen());
echo "\r\n";
var_dump((is(2007))->yearOfBirth());
echo "\r\n";
echo "Math";
echo "\r\n";
var_dump((is(4))->plus(5)->thirteen());
echo "\r\n";
var_dump((is(12))->plus(1)->thirteen());
echo "\r\n";
var_dump((is(4))->minus(12)->thirteen());
echo "\r\n";
var_dump((is(14))->minus(1)->thirteen());
echo "\r\n";
var_dump((is(1))->times(8)->thirteen());
echo "\r\n";
var_dump((is(26))->divideby(2)->thirteen());
echo "\r\n";
8 changes: 8 additions & 0 deletions src/functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

if (!function_exists('is')) {
function is($value)
{
return new \Fatkulnurk\IsThirteen\Is($value);
}
}
7 changes: 7 additions & 0 deletions vendor/autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

// autoload.php @generated by Composer

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit846024932cc7e0fb8d13d5038ae20a85::getLoader();
Loading

0 comments on commit e3b8dde

Please sign in to comment.