Skip to content
Quick condition checker library for Php and Laravel Projects
PHP
Branch: master
Clone or download
krcgk Merge pull request #21 from svenluijten/patch-1
return early in helper function
Latest commit fecb57d Jan 24, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src return early in helper function Jan 17, 2018
tests clear blank line for styleci Dec 19, 2017
.editorconfig initial commit Dec 16, 2017
.gitignore updated gitignore file Dec 19, 2017
.styleci.yml
.travis.yml another travis config 2 Dec 19, 2017
LICENCE.md initial commit Dec 16, 2017
composer.json Up to stable Dec 19, 2017
phpunit.xml dropped build logging Dec 19, 2017
readme.md update service provider Dec 19, 2017

readme.md

Is

Quick condition checker library for Php and Laravel Projects

Latest Stable Version Total Downloads License Travis StyleCI Code Climate

Usage

$is->... // whatever you want

$is->integerOrStringOrFloatOrObject( 5 ); // true
$is->notIntegerAndNotStringAndFloat( 'merhaba' ); // false
$is->unsignedIntegerOrLongOrRealOrCallable( 5 ); // true
$is->integerAndNotNull( 5 ); // true

Laravel Usage

The library comes with the provider, facade and helper

app('krcgk.is')->stringOrInteger( 'string' ); // true

// or

Is::stringOrInteger( 'string' ); // true

// or

is()->stringOrHelper( 'string' ); // instance return from container

Installation

composer require krcgk/is

Default Conditions

The library comes with the that conditions;

  • array
  • bool
  • boolean
  • callable
  • closure
  • double
  • empty
  • float
  • instanceOf
  • int
  • integer
  • long
  • null
  • numeric
  • object
  • real
  • resource
  • scalar
  • string
  • unsignedInteger

Advantage

If you want extend the library, you can use custom conditions

$is->register('planet', function() {
    
    list($context) = func_get_args();
    
    $planets = [
        'mercury',
        'venus',
        'earth',
        'mars',
        'jupiter',
        'saturn',
        'uranus',
        'neptune',
        // 'pluto' :(
    ];
    
    return in_array(mb_strtolower($context), $planets);
});

$is->stringAndPlanet('earth'); // true

$is->stringAndPlanet('pluto'); // false

Laravel Installation

to config/app.php;

    'providers' => [
  
        ///
    
        Krcgk\Is\Providers\LaravelServiceProvider::class,
    
        ///
  
    ],
  
    'aliases' => [
    
        ///
      
        'Is' => Krcgk\Is\Facades\Is::class,
      
        ///
    
    ],
You can’t perform that action at this time.