PHPackages                             josantonius/datatype - 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. josantonius/datatype

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

josantonius/datatype
====================

PHP simple library for managing of data types.

1.1.6(7y ago)4281[1 issues](https://github.com/josantonius/php-data-type/issues)MITPHPPHP ^5.6 || ^7.0

Since Dec 14Pushed 3y ago1 watchersCompare

[ Source](https://github.com/josantonius/php-data-type)[ Packagist](https://packagist.org/packages/josantonius/datatype)[ GitHub Sponsors](https://github.com/Josantonius)[ RSS](/packages/josantonius-datatype/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (8)Dependencies (4)Versions (9)Used By (0)

PHP DataType library
====================

[](#php-datatype-library)

[![Latest Stable Version](https://camo.githubusercontent.com/1647a91b46378bdf579a3b93a8c5f76be2b0a1087630fd9112251cf807b48f82/68747470733a2f2f706f7365722e707567782e6f72672f6a6f73616e746f6e6975732f44617461547970652f762f737461626c65)](https://packagist.org/packages/josantonius/DataType)[![License](https://camo.githubusercontent.com/0f7045469e75830c5fcea04c616dc76492665a93b8b3af2555e00b5c06ecd65a/68747470733a2f2f706f7365722e707567782e6f72672f6a6f73616e746f6e6975732f44617461547970652f6c6963656e7365)](LICENSE)

**This library will no longer be supported. Alternatively, you can use the** [Validate](https://github.com/Josantonius/php-validate) **library.**

[Versión en español](README-ES.md)

PHP simple library for managing of data types.

---

- [Requirements](#requirements)
- [Installation](#installation)
- [Available Methods](#available-methods)
- [Quick Start](#quick-start)
- [Usage](#usage)
- [Tests](#tests)
- [Sponsor](#Sponsor)
- [License](#license)

---

Requirements
------------

[](#requirements)

This library is supported by **PHP versions 5.6** or higher and is compatible with **HHVM versions 3.0** or higher.

Installation
------------

[](#installation)

The preferred way to install this extension is through [Composer](http://getcomposer.org/download/).

To install **PHP DataType library**, simply:

```
composer require Josantonius/DataType

```

The previous command will only install the necessary files, if you prefer to **download the entire source code** you can use:

```
composer require Josantonius/DataType --prefer-source

```

You can also **clone the complete repository** with Git:

$ git clone

Or **install it manually**:

[Download DataType.php](https://raw.githubusercontent.com/Josantonius/PHP-DataType/master/src/DataType.php):

```
wget https://raw.githubusercontent.com/Josantonius/PHP-DataType/master/src/DataType.php

```

Available Methods
-----------------

[](#available-methods)

Available methods in this library:

### - Convert object to array

[](#--convert-object-to-array)

```
DataType::objectToArray($object);
```

AttributeDescriptionTypeRequiredDefault$objectVariable of the object.objectYes**\# Return** (array) → object converted to array

Quick Start
-----------

[](#quick-start)

To use this library with **Composer**:

```
require __DIR__ . '/vendor/autoload.php';

use Josantonius\DataType\DataType;
```

Or If you installed it **manually**, use it:

```
require_once __DIR__ . '/DataType.php';

use Josantonius\DataType\DataType;
```

Usage
-----

[](#usage)

Example of use for this library:

```
$object = new \stdClass();

$object->name  = 'Josantonius';
$object->email = 'info@josantonius.com';
$object->url   = 'https://github.com/josantonius/PHP-DataType';

echo ''; var_dump(DataType::objectToArray($object)); echo '';

/*
array(3) {
  ["name"]=>
  string(11) "Josantonius"
  ["email"]=>
  string(20) "info@josantonius.com"
  ["url"]=>
  string(36) "https://github.com/josantonius/PHP-DataType"
}
*/
```

Tests
-----

[](#tests)

To run [tests](tests) you just need [composer](http://getcomposer.org/download/) and to execute the following:

```
git clone https://github.com/Josantonius/PHP-DataType.git

cd PHP-DataType

composer install

```

Run unit tests with [PHPUnit](https://phpunit.de/):

```
composer phpunit

```

Run [PSR2](http://www.php-fig.org/psr/psr-2/) code standard tests with [PHPCS](https://github.com/squizlabs/PHP_CodeSniffer):

```
composer phpcs

```

Run [PHP Mess Detector](https://phpmd.org/) tests to detect inconsistencies in code style:

```
composer phpmd

```

Run all previous tests:

```
composer tests

```

Sponsor
-------

[](#sponsor)

If this project helps you to reduce your development time, [you can sponsor me](https://github.com/josantonius#sponsor) to support my open source work 😊

License
-------

[](#license)

This repository is licensed under the [MIT License](LICENSE).

Copyright © 2016-2018, [Josantonius](https://github.com/josantonius#contact)

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity63

Established project with proven stability

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

Recently: every ~107 days

Total

8

Last Release

2838d ago

PHP version history (3 changes)1.0.0PHP &gt;=7.0

1.1.0PHP &gt;=5.6

1.1.1PHP ^5.6 || ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4b221283501ec8a9cbaefaf27821a91ae8ddd33bddf1fccc6c6815b7ad216ff1?d=identicon)[Josantonius](/maintainers/Josantonius)

---

Top Contributors

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

---

Tags

composerdeprecatedobject-to-arrayphpphp-datatype-libraryphparrayhhvmobject-to-arrayArray to object

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/josantonius-datatype/health.svg)

```
[![Health](https://phpackages.com/badges/josantonius-datatype/health.svg)](https://phpackages.com/packages/josantonius-datatype)
```

###  Alternatives

[zakirullin/mess

Convenient array-related routine &amp; better type casting

21330.0k2](/packages/zakirullin-mess)

PHPackages © 2026

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