void-sector/scalar-objects

Scalar Objects in PHP

dev-master 2015-02-07 22:04 UTC

This package is not auto-updated.

Last update: 2024-05-07 04:43:46 UTC


README

Build Status Coverage Status Scrutinizer Quality Score

Supports method calls on primitive types in PHP. Allows you to use Type Hinting on the primitives in your OO project. Values are validated when constructed using there own validators. The project is PSR-1, PSR-2 compatable.

The project is work in progress. I'm still trying to find a nice way to delegate the Operation calls following the Open/Closed Principle. Please take a look at the Open Issues for more information.

Examples

String Example:

<?php

require('./vendor/autoload.php');

use Scalar\String;

$string = new String('We love Fruit!');

$string->replace('Fruit', 'Coding');
$string->toUpper();

echo $string->getValue() . PHP_EOL; // results in: WE LOVE CODING!

Float Example:

<?php

require('./vendor/autoload.php');

use Scalar\Float;

$float = new Float(33.3333333);

$float->ceil();

echo $float->getValue() . PHP_EOL; // results in: 34.0

Contribute

If you got suggestions, idea's or improvements , please fork the project and initialize a pull request.

Happy Coding!!