\Malenki\BahH

Base object, mother of all classes of this package.

It contains some validation processes, basic magic getter to get internal value and __toString() feature.

Summary

Methods
Properties
Constants
__get()
__toString()
__set()
__isset()
__unset()
__construct()
getIterator()
current()
key()
next()
rewind()
valid()
exist()
has()
set()
take()
get()
at()
delete()
chunk()
count()
map()
walk()
search()
find()
slice()
merge()
No public properties found
No constants found
mustBeStringOrScalar()
mustBeString()
mustBeInteger()
mustBeFloat()
mustBeDouble()
mustBeNumeric()
mustBeArray()
mustBeHash()
mustBeArrayOrHash()
mustBeCallable()
_array()
_arr()
_length()
_keys()
_values()
_reverse()
_sort()
_unique()
$value
$count
$position
N/A
No private methods found
No private properties found
N/A

Properties

$value

$value : mixed

Type

mixed — Primitive value

$count

$count : 

Type

$position

$position : 

Type

Methods

__get()

__get( $name) : mixed

Magic getters engine.

By default, return internal O::$value attribute.

Parameters

$name

Returns

mixed

__toString()

__toString() : string

Convert current object into string when this is in string context.

Returns

string

__set()

__set( $name,  $value)

Parameters

$name
$value

__isset()

__isset( $name)

Parameters

$name

__unset()

__unset( $name)

Parameters

$name

__construct()

__construct( $arr)

Parameters

$arr

getIterator()

getIterator()

current()

current()

key()

key()

next()

next()

rewind()

rewind()

valid()

valid()

exist()

exist( $key)

Parameters

$key

has()

has( $thing)

Parameters

$thing

set()

set( $key,  $value)

Parameters

$key
$value

take()

take( $key)

Parameters

$key

get()

get( $key)

Parameters

$key

at()

at( $key)

Parameters

$key

delete()

delete( $key)

Parameters

$key

chunk()

chunk( $size)

Parameters

$size

count()

count()

map()

map( $func)

Parameters

$func

walk()

walk( $func,  $other)

Parameters

$func
$other

search()

search(mixed $foo) : mixed

Search index of the given element.

This will return the first index found for the given element if there are several identical.

If no element found, then return null.

If element is found, then S object is returned.

Parameters

mixed $foo

The element to find

Returns

mixed

find()

find( $pattern)

Parameters

$pattern

slice()

slice( $offset,  $length)

Parameters

$offset
$length

merge()

merge( $arr)

Parameters

$arr

mustBeStringOrScalar()

mustBeStringOrScalar(mixed $arg, string $arg_name) : void

Checks whether given value is string-like or scalar type.

Value must be of string-like type (string or object having __toString() method) or a basic scalar type.

The aim of this method is only to raise \InvalidArgumentException if given value has not the good type.

Parameters

mixed $arg

The value to test.

string $arg_name

Optional name of the value, used into exception’s message.

Throws

\InvalidArgumentException

If value’s type is not valid

mustBeString()

mustBeString(mixed $arg, string $arg_name) : void

Checks whether given value is string-like type.

A string-like value is string or object having __toString() method.

The aim of this method is only to raise \InvalidArgumentException if given value has not the good type.

Parameters

mixed $arg

The value to test.

string $arg_name

Optional name of the value, used into exception’s message.

Throws

\InvalidArgumentException

If value’s type is not valid

mustBeInteger()

mustBeInteger(mixed $arg, string $arg_name) : void

Checks whether given value is integer-like type.

An integer-like value is integer or \Malenki\Bah\N object.

The aim of this method is only to raise \InvalidArgumentException if given value has not the good type.

Parameters

mixed $arg

The value to test.

string $arg_name

Optional name of the value, used into exception’s message.

Throws

\InvalidArgumentException

If value’s type is not valid

mustBeFloat()

mustBeFloat(mixed $arg, string $arg_name) : void

Checks whether given value is float-like type.

A float-like value is float or \Malenki\Bah\N object.

The aim of this method is only to raise \InvalidArgumentException if given value has not the good type.

Parameters

mixed $arg

The value to test.

string $arg_name

Optional name of the value, used into exception’s message.

Throws

\InvalidArgumentException

If value’s type is not valid

mustBeDouble()

mustBeDouble(mixed $arg, string $arg_name) : void

Checks whether given value is double-like type.

A double-like value is string or \Malenki\Bah\N object.

The aim of this method is only to raise \InvalidArgumentException if given value has not the good type.

Parameters

mixed $arg

The value to test.

string $arg_name

Optional name of the value, used into exception’s message.

Throws

\InvalidArgumentException

If value’s type is not valid

mustBeNumeric()

mustBeNumeric(mixed $arg, string $arg_name) : void

Checks whether given value is numeric-like type.

A numeric-like value is numeric (integer, float or double) or \Malenki\Bah\N object.

The aim of this method is only to raise \InvalidArgumentException if given value has not the good type.

Parameters

mixed $arg

The value to test.

string $arg_name

Optional name of the value, used into exception’s message.

Throws

\InvalidArgumentException

If value’s type is not valid

mustBeArray()

mustBeArray(mixed $arg, string $arg_name) : void

Checks whether given value is an array-like type.

A array-like value is an array or \Malenki\Bah\A object.

The aim of this method is only to raise \InvalidArgumentException if given value has not the good type.

Parameters

mixed $arg

The value to test.

string $arg_name

Optional name of the value, used into exception’s message.

Throws

\InvalidArgumentException

If value’s type is not valid

mustBeHash()

mustBeHash(mixed $arg, string $arg_name) : void

Checks whether given value is a hash-like type.

A hash-like value is an array having named-index or \Malenki\Bah\H object.

The aim of this method is only to raise \InvalidArgumentException if given value has not the good type.

Parameters

mixed $arg

The value to test.

string $arg_name

Optional name of the value, used into exception’s message.

Throws

\InvalidArgumentException

If value’s type is not valid

mustBeArrayOrHash()

mustBeArrayOrHash(mixed $arg, string $arg_name) : void

Checks whether given value is an array-like or hash-like type.

The aim of this method is only to raise \InvalidArgumentException if given value has not the good type.

Parameters

mixed $arg

The value to test.

string $arg_name

Optional name of the value, used into exception’s message.

Throws

\InvalidArgumentException

If value’s type is not valid

mustBeCallable()

mustBeCallable(mixed $arg, mixed $arg_name) : void

Checks whether the given argument is callable.

This is usefull to test is an argument can be call as a function. If this argument is not callable, then this raises an \InvalidArgumentException.

Parameters

mixed $arg

The value to test

mixed $arg_name

Optional name of the value, used into error message

Throws

\InvalidArgumentException

If arg is not callable

_array()

_array()

_arr()

_arr()

_length()

_length()

_keys()

_keys()

_values()

_values()

_reverse()

_reverse()

_sort()

_sort()

_unique()

_unique()