PHPackages                             net\_bazzline/component\_data\_type - 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. net\_bazzline/component\_data\_type

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

net\_bazzline/component\_data\_type
===================================

php component data type

1.1.0(12y ago)072LGPLv3PHPPHP &gt;=5.3.3

Since Aug 4Pushed 12y ago1 watchersCompare

[ Source](https://github.com/stevleibelt/php_component_data_type)[ Packagist](https://packagist.org/packages/net_bazzline/component_data_type)[ Docs](https://github.com/stevleibelt/php_component_data_type)[ RSS](/packages/net-bazzline-component-data-type/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

PHP Component - Data Type
=========================

[](#php-component---data-type)

This component includes class definitions for php basic data types like:

- Boolean
- Floating point
- Integer
- String
- Numeric
- DataArray

By using this component, you are able to use type hints also for basic data types.

The build status of the current master branch is tracked by Travis CI: [![Build Status](https://camo.githubusercontent.com/561ff2b281dcfb130c429e33ee695da4889e70c149e8076a834376b00eac7d27/68747470733a2f2f7472617669732d63692e6f72672f737465766c656962656c742f7068705f636f6d706f6e656e745f646174615f747970652e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/stevleibelt/php_component_data_type)

Features
========

[](#features)

- Enables type hints for basic php types
- Types shipped with useful methods
- Are comparable with native php types by using "=="
- Provides generic type casting by implemented "toString()" methods (and so on)
- Provides type migration by *from* and *to* methods

Usage
=====

[](#usage)

Example
-------

[](#example)

```
/**
 * Class with type hint for string
 *
 * @author stev leibelt
 * @since 2013-08-04
 */
class MyClass
{
    /**
     * @var array
     * @author stev leibelt
     * @since 2013-08-04
     */
    private $strings = array();

    /**
     * Super cool method with type hint for string
     *
     * @author stev leibelt
     * @since 2013-08-04
     */
    public function addString(\Net\Bazzline\Component\DataType\String $string)
    {
        $this->strings[] = $string;

        return $this;
    }
}

$myString = new \Net\Bazzline\Component\DataType\String('super cool test string');

$myClass = new MyClass();
$myClass->addString($myString);
```

Hints
-----

[](#hints)

- Extend provided types with classes in own namespace.
- If you add a super cool method to your type, push it and be a part of the development team

Install
=======

[](#install)

Via Git
-------

[](#via-git)

```
cd path/to/my/git/respositories
mkdir -p stevleibelt/php_component_data_type
cd stevleibelt/php_component_data_type

git clone git://github.com/stevleibelt/php_component_data_type.git .
```

Via Composer
------------

[](#via-composer)

```
require: "net_bazzline/component_data_type": "dev-master"
```

Why?
====

[](#why)

I started developing this component because of the many casts i have to do while dealing with php's basic data types. As general, i searched the web for existing and easy to use components but could not find them. If you find one, please tell me. Last but not least [SplTypes](http://php.net/manual/en/intro.spl-types.php) are still experimental.

To Do
=====

[](#to-do)

- Cover existing unittest with validation of implemented interfaces
- Can we use [pack](http://de2.php.net/manual/en/function.pack.php)?
- Add modulo to Numeric
- Add locking (mark a value as read only)
- Add Date type -&gt; check [Joda Time](http://joda-time.sourceforge.net/)
- Add Time type
- Add DateTime type
- Add arrayAccess to string
- Add collection
- Add examples
- Add benchmarks
- [Option type](https://github.com/schmittjoh/php-option)?
- [Enum](https://github.com/marc-mabe/php-enum)?
- Add [invoke](http://www.php.net/manual/en/language.oop5.magic.php#object.invoke) to String?

Links
=====

[](#links)

Following are links i found and used for creating this component.

- [type juggling](http://php.net/manual/en/language.types.type-juggling.php)
- [type casing](http://www.phpro.org/tutorials/PHP-Type-Casting.html#4.7)
- [machine data type](http://en.wikipedia.org/wiki/Data_type#Machine_data_types)
- [list of php resource types](http://php.net/manual/en/resource.php)
- [php\_component\_data\_type at ohloh.net](https://www.ohloh.net/p/php_component_data_type)

Other Implementations
---------------------

[](#other-implementations)

- [h4kuna/data-type](https://github.com/h4kuna/data-type)

History
=======

[](#history)

- next
    - Coverd existing classes with "ableInterface" where each defines a *from$Type* and *to$Type* method
    - Started class for array called DataArray
    - Implemented usage of LockInterface, now you can lock a datatype to prevent from value changes
- [1.1.0](https://github.com/stevleibelt/php_component_data_type/tree/1.1.0)
    - Updated readme
    - Implemented *isEmpty* method which leads to different behaviour while creating an object
- [1.0.0](https://github.com/stevleibelt/php_component_data_type/tree/1.0.0)
    - Finished data type Boolean
    - Finished data type FloatingPoint
    - Finished data type Numierc
    - Finished data type Integer
    - Finished data type String

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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 ~0 days

Total

2

Last Release

4714d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/58451b041f6f5a38c7e62762c96d01f5e2bcac30e322707fe4760a82bccb6856?d=identicon)[artodeto](/maintainers/artodeto)

---

Top Contributors

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

---

Tags

phpstringintegercomponentnumberfloatdata typebooleannet\_bazzline

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/net-bazzline-component-data-type/health.svg)

```
[![Health](https://phpackages.com/badges/net-bazzline-component-data-type/health.svg)](https://phpackages.com/packages/net-bazzline-component-data-type)
```

###  Alternatives

[kwn/number-to-words

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

4375.4M23](/packages/kwn-number-to-words)[coduo/php-to-string

Simple library that converts PHP value into strings

27013.4M14](/packages/coduo-php-to-string)[jstewmc/php-helpers

Static classes to help with numbers, strings, arrays, files, and bools in PHP

3111.6k2](/packages/jstewmc-php-helpers)[danog/phpstruct

PHP implementation of python's struct module.

1110.5k](/packages/danog-phpstruct)

PHPackages © 2026

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