2017 © Pedro Peláez
 

library php-type-checker

Type checker for base types or list of types or arrays

image

new-inventor/php-type-checker

Type checker for base types or list of types or arrays

  • Thursday, October 12, 2017
  • by George Ionov
  • Repository
  • 1 Watchers
  • 0 Stars
  • 426 Installations
  • PHP
  • 6 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 18 Versions
  • 2 % Grown

The README.md

PHP type checker

Проверяет совпадение типа переменной с указанными типами. Может бросить исключение если необходимо., (*1)

Установка

через composer, (*2)

composer require new-inventor/php-type-checker, (*3)

Принцип работы

Вызываем статический метод TypeChecker::check($value), (*4)

Теперь можно проверять типы., (*5)

Простые типы: * array * bool * callable * float * int * null * numeric * object * resource * scalar * string, (*6)

Для проверки простых типов необходимо сделать следующее:, (*7)

TypeChecker::check($value)->tint()->tstring()->fail() или TypeChecker::check($value)->tint()->tstring()->result(), (*8)

  • метод fail() предназначен для бросания исключения(TPMailSender\TypeChecker\Exception\TypeException)
  • метод result() предназначен для возвращения результата проверки

Если надо проверить элементы параметра-массива то необходимо вызвать метод inner() и после него определять типы. Можно не вызывать функцию tarray() перед вызовом метода inner(), (*9)

TypeChecker::check($value)->tstring()->tarray()->tint()->inner()->tint()->tstring()->result() проверка внутренних элементов будет происходить, только если параметр является массивом., (*10)

Для проверки типов объектов вызвается метод types() в параметрах которого перечисляются полные имена типов, (*11)

TypeChecker::check($value)->types(MyClass::class, MyAnotherClass::class), (*12)

если нужна более сложная проверка то используйте метод callback(callable $callback), (*13)

self::param()->tint()->tfloat()->tstring()->callback(function ($value){
    return is_object($value) && method_exists($value, '__toString');
});

The Versions

12/10 2017

dev-master

9999999-dev

Type checker for base types or list of types or arrays

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Avatar George Ionov

12/10 2017

5.0.1

5.0.1.0

Type checker for base types or list of types or arrays

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Avatar George Ionov

18/09 2017

5.0.0

5.0.0.0

Type checker for base types or list of types or arrays

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Avatar George Ionov

01/09 2017

4.2.0

4.2.0.0

Type checker for base types or list of types or arrays

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Avatar George Ionov

01/09 2017

4.1.0

4.1.0.0

Type checker for base types or list of types or arrays

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Avatar George Ionov

31/08 2017

4.0.2

4.0.2.0

Type checker for base types or list of types or arrays

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Avatar George Ionov

31/08 2017

4.0.1

4.0.1.0

Type checker for base types or list of types or arrays

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Avatar George Ionov

31/08 2017

4.0.0

4.0.0.0

Type checker for base types or list of types or arrays

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Avatar George Ionov

31/08 2017

3.1.1

3.1.1.0

Type checker for base types or list of types or arrays

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Avatar George Ionov

31/08 2017

3.1.0

3.1.0.0

Type checker for base types or list of types or arrays

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Avatar George Ionov

31/08 2017

3.0.0

3.0.0.0

Type checker for base types or list of types or arrays

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

by Avatar George Ionov

30/08 2017

2.0.4

2.0.4.0

Type checker for base types or list of types or arrays

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

by Avatar George Ionov

29/08 2017

2.0.3

2.0.3.0

Type checker for base types or list of types or arrays

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

by Avatar George Ionov

14/10 2016

2.0.2

2.0.2.0

Type checker for base types or list of types or arrays

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

by Avatar George Ionov

14/10 2016

2.0.1

2.0.1.0

Type checker for base types or list of types or arrays

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

by Avatar George Ionov

14/10 2016

2.0.0

2.0.0.0

Type checker for base types or list of types or arrays

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

by Avatar George Ionov

01/04 2016

1.0.1

1.0.1.0

Type checker for base types or list of types or arrays

  Sources   Download

MIT

The Requires

 

The Development Requires

by Georgy Ionov

01/04 2016

1.0.0

1.0.0.0

Type checker for base types or list of types or arrays

  Sources   Download

MIT

The Requires

 

The Development Requires

by Georgy Ionov