PHPackages                             bluepsyduck/common - 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. bluepsyduck/common

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

bluepsyduck/common
==================

Some classes commonly used in other projects.

1.0.1(7y ago)13.0kGPL-3.0-or-laterPHPPHP &gt;=7.0.0

Since Feb 16Pushed 7y ago1 watchersCompare

[ Source](https://github.com/BluePsyduck/Common)[ Packagist](https://packagist.org/packages/bluepsyduck/common)[ Docs](https://github.com/BluePsyduck/Common)[ RSS](/packages/bluepsyduck-common/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

BluePsyduck's Common Library
============================

[](#bluepsyducks-common-library)

[![Latest Stable Version](https://camo.githubusercontent.com/d54f81c1ed1e55f6115995b8c1bb76501f793d9238cee2c01a6d2ed02a295c32/68747470733a2f2f706f7365722e707567782e6f72672f626c75657073796475636b2f636f6d6d6f6e2f762f737461626c65)](https://packagist.org/packages/bluepsyduck/common) [![Total Downloads](https://camo.githubusercontent.com/233ab58e683964a00e53cbb4bf114f3aebcc44d3d3c482d7960599da31b3413a/68747470733a2f2f706f7365722e707567782e6f72672f626c75657073796475636b2f636f6d6d6f6e2f646f776e6c6f616473)](https://packagist.org/packages/bluepsyduck/common) [![License](https://camo.githubusercontent.com/8b9f6d2a1690bb1d908ecc0ff625ab604ad0dd8bc709b75c0c34f1ec89d4221c/68747470733a2f2f706f7365722e707567782e6f72672f626c75657073796475636b2f636f6d6d6f6e2f6c6963656e7365)](https://packagist.org/packages/bluepsyduck/common) [![Build Status](https://camo.githubusercontent.com/7c52a13f2d029b5f5580a31ec03a2b490278d1e6124fb77b06513263a8bc8ec1/68747470733a2f2f7472617669732d63692e6f72672f426c75655073796475636b2f436f6d6d6f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/BluePsyduck/Common) [![codecov](https://camo.githubusercontent.com/83944890d72ad337e30e7d94753cbd1f000c540e28d52c6b1a5a256b7533c3a6/68747470733a2f2f636f6465636f762e696f2f67682f426c75655073796475636b2f436f6d6d6f6e2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/BluePsyduck/Common)

This library contains some classes commonly used in other projects.

DataBuilder
-----------

[](#databuilder)

The data builder is a class helping with building up an array with different values, ensuring that the values have the correct type. With all methods a default value can be specified which should be ignored and not added to the data array.

The data builder provides several methods for automatically casting the set values:

- **setBoolean():** Sets a boolean value.
- **setInteger():** Sets an integer number.
- **setFloat():** Sets a floating point number.
- **setString():** Sets a string value.
- **setDateTime():** Sets a date and time value in the specified format. If the passed value is not a `DateTime`instance, the value gets ignored automatically.
- **setArray():** Sets an array of value, optionally with a mapping method to e.g. cast each value.

###### Example

[](#example)

```
