agmakonts / stl
Standard Type Lib
Installs: 2 195
Dependents: 3
Suggesters: 0
Security: 0
Stars: 6
Watchers: 5
Forks: 2
Open Issues: 1
Requires
- php: >=5.5
- marc-mabe/php-enum: 2.0.*
- ramsey/uuid: 2.8.*
Requires (Dev)
- devster/ubench: 1.1.*
- fzaninotto/faker: 1.5.*@dev
- phpunit/phpunit: 4.3.4
README
Simple Type Lib for PHP
Library inspired by nicolopignatelli/valueobjects. My goal was to create
a set of classes that will serve as a object oriented implementation of basic data types to fight with PHPs dynamic types and at the same time add few extra classes for
common tasks. One of the main features of STL is that all objects have one instance per value String::get('Test') === String::get('Test')
. Thanks to that approach
it is easy to store objects in for example SPLObjectStorage
or similar containers that depend od object hash.
All objects are immutable - this is required because instances are shared.
Requirements
- PHP >= 5.4
- OpenSSL Extension
Quick start
//Create or get String instance $string = String::get('String value'); //Create or get Integer instance $integer = Integer::get(12213); //Chaining $integer = Integer::get(10)->add(Integer::get(10));
Library parts description
Number
All classes in \Number
namespace are designed to handle numeric types. Decimal internally uses strings for compatibility
with bcmath functions but interface exposes scalar numbers.
DateTime
...
Roadmap
Currently, after quite a big rebuild (that is still in progress) only String is implemented almost fully, rest of planned data types and value objects is listed below:
- Number
- Integer - Ready
- Decimal - Ready
- Fraction
- DateTime
- Date
- Year
- Month
- Week
- Day
- Time
- Hour
- Minute
- Second
- DateTime - Started
- Structure
- TypedArray
- TypedList
- Dictionary
- Identity
- UUID
- Numeric
- Alphanumeric
- Autonumeric - Ready
- Text
- Word
- Sentence
- Paragraph