Download the PHP package k-gun/xo without Composer
On this page you can find all versions of the php package k-gun/xo. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package xo
Short Description A few well e(x)tended (o)bjects that make easy to build strictly typed arrays such as Map, Set, Tuple or any type of TypedArray's, and also String and Number's.
License MIT
Homepage http://github.com/k-gun/xo
Informations about the package xo
XO is a library that provides some e(x)tended (o)bjects to build strictly typed arrays such as Map, Set, Tuple or any type of TypedArray's, and also String and Number objects that are not objects natively in PHP.
You can use Map
, Set
and Tuple
to build strict arrays and also use AnyArray
(ArrayObject
and Collection
are just aliases of it) derived from AbstractArray
that contains many native-equal array methods or StringObject
and NumberObject
to use AbstractScalarObject
interface.
All XO objects extends AbstractObject
, so that makes possible to use some basic object methods like getName()
or getShortName()
.
In a Nutshell
Installation
Use can also download and use without Composer including boot.php
.
Using Array Objects
Basically there are 5 types of array in XO;
TypedArray: Int
or String
keyed object derived from AbstractArray.
AnyArray: String
keyed object derived from TypedArray.
Map: String
keyed object derived from TypedArray.
Set: Int
keyed object derived from TypedArray.
Tuple: Int
keyed and read-only
object derived from TypedArray.
But, off course, you can create new typed array objects via TypedArray
directly like in first example or defining new arrays that extend TypedArray
or other objects such as Map
, Set
, Tuple
or AnyArray
.
Typed array example;
Yet another example;
If you want to make a untyped array, you can simply use AnyArray
. So that will provide all methods as well likely on the other arrays.
Here is another example with AnyArray
like above;
Custom Arrays
Creating custom arrays;
Besides, it also possible with Set
or Map
;
Using String and Number Objects
Objects, Object Methods and Properties
-
AbstractObject
-
AbstractArray
-
TypedArray
-
AnyArray
-
Map
-
Set
-
Tuple
-
ArrayObject
andCollection
-
AbstractScalarObject
-
StringObject
-
NumberObject
Static and Util Objects
-
StaticClass
-
Type
-
Util
-
ArrayUtil
-
NumberUtil
-
StringUtil
Exceptions
class xo\exception\Exception extends Exception {}
class xo\ArrayException extends xo\exception\Exception {}
class xo\StaticClassException extends xo\exception\Exception {}
class xo\util\UtilException extends xo\exception\Exception {}
class xo\exception\ArgumentException extends xo\exception\Exception {}
class xo\exception\ArgumentTypeException extends xo\exception\Exception {}
class xo\exception\KeyException extends xo\exception\Exception {}
class xo\exception\ValueException extends xo\exception\Exception {}
class xo\exception\MethodException extends xo\exception\Exception {}
class xo\exception\MutationException extends xo\exception\Exception {}
class xo\exception\NullException extends xo\exception\Exception {}
class xo\exception\TypeException extends xo\exception\Exception {}
Shortcut Functions
map(...$arguments): xo\Map
set(...$arguments): xo\Set
tuple(...$arguments): xo\Tuple
collection(...$arguments): xo\Collection
string(string $value): xo\StringObject
number(numeric $value): xo\NumberObject