PHPackages                             dozer111/type\_checker - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. dozer111/type\_checker

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

dozer111/type\_checker
======================

Check your variable types using using less code

2.1(6y ago)0660proprietaryPHPPHP &gt;7.1

Since May 7Pushed 5y ago1 watchersCompare

[ Source](https://github.com/dozer111/typeChecker)[ Packagist](https://packagist.org/packages/dozer111/type_checker)[ RSS](/packages/dozer111-type-checker/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (3)Dependencies (4)Versions (6)Used By (0)

PHP type checker
================

[](#php-type-checker)

`composer require dozer111/type_checker`

Was created, for better and faster checking `$yourValue` data types in imperativeStyle

---

**Main idea** , that there is no need to write and read after looong checks(which takes our time and energy), when we can change it to some simple structure, which would do code shorter and readPrettier

---

Lib has 2 main ways:

- **check**
- **hardCheck/guard** =&gt; check, and if false -&gt; throw exception

```
TypeChecker::hardCheck($value,[__INTEGER__,__STRING__]);
TypeChecker::hardCheckInt($value,[__INTEGER__,__STRING__]);
TypeChecker::hardCheckString($value,[__INTEGER__,__STRING__]);
// or same, but with synonyms
TypeChecker::guard($value,[__INTEGER__,__STRING__]);
TypeChecker::guardInt($value,[__INTEGER__,__STRING__]);
TypeChecker::guardString($value,[__INTEGER__,__STRING__]);
```

### Example1 =&gt; common usage

[](#example1--common-usage)

```
//before
$value = '';
if(is_int($value) || is_string($value))
{
    doSmth();
}

// now
$valueHasCorrectType = TypeChecker::check($value,[__INTEGER__,__STRING__]);

//========================================================================================================================
//========================================================================================================================

// before
if(is_int($value) || is_string($value))
{
    throw new SomeYourException();
}

// now hardCheck or guard
TypeChecker::hardCheck($value,[__INTEGER__,__STRING__]);
TypeChecker::guard($value,[__INTEGER__,__STRING__]);
```

### Example2 =&gt; value + nullable

[](#example2--value--nullable)

TypeChecker has own type `TYPE_NULL`, and you can use this.
Also, you can use `nullable` argument, instead of adding this to `check()` method:

```
// add manually
TypeChecker::check($value,[__INTEGER__,__STRING__,__NULL__]);
// or use nullable mechanism
TypeChecker::check($value,[__INTEGER__,__STRING__],true);
```

---

This trick works almost for all methods:

```
TypeChecker::hardCheckInt($x,true); // null or int
TypeChecker::hardCheckInt($x); // int ONLY!
```

### Example3 =&gt; checking Object

[](#example3--checking-object)

- TypeChecker can check object in 2 ways
    - check, that value is just `object` type
    - check, that object really instanceOf your needs

```
// we can check objects in couple of ways:
// 1 => using TypeChecker::check
TypeChecker::check($value,[__OBJECT__]);
TypeChecker::check($value,[YorClassName::class]);

// 2 => TypeChecker::checkObject()/TypeChecker::hardCheckObject()
TypeChecker::checkObject($value); // will check for `object` type
TypeChecker::checkObject($value,YorClassName::class); // will check for `object` && YorClassName types
TypeChecker::checkObject($value,YorClassName::class,true); // will check for (`object` && YorClassName) or null types
```

### Example4 =&gt; change default throw exception

[](#example4--change-default-throw-exception)

just extends class, and rewrite `throwHardCheckError()`

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

3

Last Release

2197d ago

Major Versions

1.0 → 2.02020-05-07

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/33666699?v=4)[Olex Khonko](/maintainers/dozer111)[@dozer111](https://github.com/dozer111)

---

Top Contributors

[![dozer111](https://avatars.githubusercontent.com/u/33666699?v=4)](https://github.com/dozer111 "dozer111 (4 commits)")

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/dozer111-type-checker/health.svg)

```
[![Health](https://phpackages.com/badges/dozer111-type-checker/health.svg)](https://phpackages.com/packages/dozer111-type-checker)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
