# Classes

# NelsonMartell\Collections\Collection

Clase base de una colección de objetos, que provee una implementación predeterminada de la interfaz ICollection.

Extends NelsonMartell\StrictObject
Implements NelsonMartell\Collections\ICollection
NelsonMartell\IComparer
NelsonMartell\IConvertibleToString
NelsonMartell\IStrictPropertiesContainer
Uses NelsonMartell\Collections\CollectionIterator
NelsonMartell\PropertiesHandler
Since v0.4.0
Authors Nelson Martell <nelson6e65@gmail.com>

# \NelsonMartell\Collections\Collection Constants

This class has not constants.

# \NelsonMartell\Collections\Collection Methods

__construct ( )


Constructor.

public function __construct(  ) : void

__invoke ( ) final


public function __invoke( mixed $index, mixed $value = null ) : void
Parameter Type(s) Description
$index mixed
$value optional mixed

add ( )


Agrega un nuevo elemento al final de la colección.

public function add( mixed $item ) : void
Parameter Type(s) Description
$item mixed Elemento que se va a agregar a la colección.

Description:

Nota para herederos: Para cambiar el comportamiento de este método, reemplazar más bien el método protegido 'insertItem'.

clear ( )


Quita todos los elementos de la colección.

public function clear(  ) : void

Description:

Nota para herederos: Para cambiar el comportamiento de este método, reemplazar más bien el método protegido Collection::clearItems.

See also \NelsonMartell\Collections\Collection::clearItems()

clearItems ( )


Quita todos los elementos de la colección.

protected function clearItems(  ) : void

contains ( )


Determina si la colección contiene al elemento especificado.

public function contains( mixed $item ) : boolean
Parameter Type(s) Description
$item mixed Objeto que se va a buscar.

Returns:

true si $item se encuentra; en caso contrario, false.

getCount ( )


Getter for $count property.

public function getCount(  ) : integer

Description:

Si extiende la clase NelsonMartell.Object, puede accederse desde la propiedad Count.

getItem ( )


Obtiene el elemento almacenado en el índice especificado.

protected function getItem( integer $index ) : mixed
Parameter Type(s) Description
$index integer Índice del elemento a obtener.

Description:

Este método no lanza excepción en caso de indicar un índice fuera del rango; en cambio, devuelve NULL. El elemento obtenido es de sólo lectura. Para modificar el elemento dentro de la colección, tendría que utilizarse el método Collection::setItem una vez modificado.

insertItem ( )


Inserta un nuevo elemento a la colección, en el índice especificado.

protected function insertItem( integer $index, mixed $newItem ) : void
Parameter Type(s) Description
$index integer Índice del elemento a insertar.
$newItem mixed Nuevo elemento a insertar a la colección.

remove ( )


Quita, si existe, la primera aparición de un objeto específico de la colección.

public function remove( mixed $item ) : boolean
Parameter Type(s) Description
$item mixed Objeto que se va a quitar.

Returns:

true si el elemento se ha quitado correctamente; en caso contrario, false. Este método también devuelve false si no se encontró.

removeItem ( )


Remove the item in specified index.

protected function removeItem( integer $index ) : void
Parameter Type(s) Description
$index integer Index.

setItem ( )


Establece un elemento en el índice especificado.

protected function setItem( integer $index, mixed $newItem ) : void
Parameter Type(s) Description
$index integer Índice del elemento a establecer.
$newItem mixed Nuevo valor con el que se va a reemplazar.

toString ( )


Gets the string representation of this object collection.

public function toString( string $format = 'r' ) : string
Parameter Type(s) Description
$format optional string String format (optional). By default, r.

Description:

You can format the output, by setting $format param to one of this options:

  • R or r: All items, separated by comma and space (,). This is the default format.
  • L or l: Same as r option, but enclosed in braces ({, }).
  • g: A full string, containing class name, items count and items list (this list, like L option).
  • G: Same as g, but using a full class name (including namespace).

You can also use a custom format instead, using this placeholders:

  • {class}: Short class name (without namespace part);
  • {nsclass}: Full class name (included namespace);
  • {count}: Items count; and
  • {items}: List of items, using comma and space (,) as separator.

Example: For a instance with 10 elements (numbers: 1-10), using: Collection::ToString('My collection ({count} items): { {items} }'); Result: 'My collection (10 items): { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }'

See also \NelsonMartell\Extensions\Text::format()

# \NelsonMartell\Collections\Collection Inherited methods

# \NelsonMartell\Collections\Collection Properties

$count


public $count;

Types:

  • integer

Description:

Obtiene el número de elementos incluidos en la colección. Esta propiedad es de sólo lectura.

# \NelsonMartell\Collections\Collection Inherited properties

This class has not inherited properties.

# NelsonMartell\Extensions\Arrays

Provides extension methods to handle arrays.

Extends Nothing
Implements NelsonMartell\IComparer
Uses Nothing
Since v1.0.0
Authors Nelson Martell <nelson6e65@gmail.com>

# \NelsonMartell\Extensions\Arrays Constants

This class has not constants.

# \NelsonMartell\Extensions\Arrays Methods

compare ( ) static


Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.

public static function compare( array|mixed $left, array|mixed $right ) : integer|null
Parameter Type(s) Description
$left array
mixed
Object to which the relative position will be determined.
$right array
mixed
The second object to compare.

Description:

This methods is specific for the case when one of them are array. In other case, will fallback to Objects::compare().You should use it directly instead of this method as comparation function forusort()`.

Since v1.0.0: Move implementation of array comparation from Objects::compare().
See also \NelsonMartell\Extensions\Objects::compare()

Returns:

Returns null if one of them is not an array.

ensureIsArray ( ) static


Ensures that object given is an array. Else, throw an exception.

public static function ensureIsArray( mixed $obj ) : array
Parameter Type(s) Description
$obj mixed Object to validate.

Returns:

Same object given.

# \NelsonMartell\Extensions\Arrays Inherited methods

This class has not inherited methods.

# \NelsonMartell\Extensions\Arrays Properties

This class has not properties.

# \NelsonMartell\Extensions\Arrays Inherited properties

This class has not inherited properties.

# NelsonMartell\Extensions\MethodExtension

Provides extension methods to handle class, trait and interface methods.

Extends Nothing
Implements Nothing
Uses Nothing
Since v1.0.0
Authors Nelson Martell <nelson6e65@gmail.com>

# \NelsonMartell\Extensions\MethodExtension Constants

This class has not constants.

# \NelsonMartell\Extensions\MethodExtension Methods

ensureIsDefined ( ) static


Ensures the method is defined in the specified class.

public static function ensureIsDefined( string $method, string $class ) : string
Parameter Type(s) Description
$method string
$class string
See also \NelsonMartell\Extensions\PropertyExtension::ensureIsValidName()

ensureIsValidName ( ) static


Ensures that a string is a valid property name.

public static function ensureIsValidName( string $name ) : string
Parameter Type(s) Description
$name string Method name to be ensured.
See also \NelsonMartell\Extensions\Text::ensureIsValidVarName()

# \NelsonMartell\Extensions\MethodExtension Inherited methods

This class has not inherited methods.

# \NelsonMartell\Extensions\MethodExtension Properties

This class has not properties.

# \NelsonMartell\Extensions\MethodExtension Inherited properties

This class has not inherited properties.

# NelsonMartell\Extensions\Numbers

Provides extension methods to handle numbers.

Extends Nothing
Implements NelsonMartell\IComparer
Uses Nothing
Since v1.0.0
Authors Nelson Martell <nelson6e65@gmail.com>

# \NelsonMartell\Extensions\Numbers Constants

This class has not constants.

# \NelsonMartell\Extensions\Numbers Methods

compare ( ) static


Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.

public static function compare( float|integer|mixed $left, float|integer|mixed $right ) : integer|null
Parameter Type(s) Description
$left float
integer
mixed
Object to which the relative position will be determined.
$right float
integer
mixed
The second object to compare.

Description:

This methods is specific for the case when one of them are numeric. In other case, will fallback to Objects::compare().You should use it directly instead of this method as comparation function forusort()`.

Since v1.0.0
See also \NelsonMartell\Extensions\Objects::compare()

ensureIsNumeric ( ) static


Ensures that object given is an integer. Else, thows an exception.

public static function ensureIsNumeric( float|integer|mixed $obj ) : float|integer
Parameter Type(s) Description
$obj float
integer
mixed
Object to validate.

Returns:

Same object given, but ensured that is a number.

# \NelsonMartell\Extensions\Numbers Inherited methods

This class has not inherited methods.

# \NelsonMartell\Extensions\Numbers Properties

This class has not properties.

# \NelsonMartell\Extensions\Numbers Inherited properties

This class has not inherited properties.

# NelsonMartell\Extensions\Objects

Provides extension methods to handle numbers.

Extends Nothing
Implements NelsonMartell\IComparer
Uses Nothing
Since v1.0.0
Authors Nelson Martell <nelson6e65@gmail.com>

# \NelsonMartell\Extensions\Objects Constants

This class has not constants.

# \NelsonMartell\Extensions\Objects Methods

compare ( ) static


Determines the relative position of the object on the left with respect to the one on the right.

public static function compare( mixed $left, mixed $right ) : integer|null
Parameter Type(s) Description
$left mixed Left object.
$right mixed Right object.

Description:

This method is compatible with core types and other types. You can implement NelsonMartell\IComparable in order to improve the beaviour for other classes.

This method can be used as sorting function for usort() function.

Notes:

  • Comparison is made in natural way if they are of the same type. If not, is used the PHP standard comparison.
  • If $left and $right are arrays, comparison is made by first by 'key' (as strings) and then by 'values' (using this method recursively).

Override: You can override this method to implement a contextual sorting behaviour for usort() function. If you only need to compare instances of your class with other objects, implement NelsonMartell\IComparable instead.

Since v1.0.0: Moved from StrictObject::compare().
See also \strnatcmp()
\usort()
\NelsonMartell\Extensions\Arrays::compare()
\NelsonMartell\IComparable
\NelsonMartell\IComparable::compareTo()
\NelsonMartell\IComparer::compare()
\NelsonMartell\Extensions\Numbers::compare()
\NelsonMartell\Extensions\Text::compare()

Returns:

Returns:

  • = 0 if $left is considered equivalent to $other;
  • > 0 if $left is considered greater than $other;
  • < 0 if $left is considered less than $other;
  • null if $left can't be compared to $other .

# \NelsonMartell\Extensions\Objects Inherited methods

This class has not inherited methods.

# \NelsonMartell\Extensions\Objects Properties

This class has not properties.

# \NelsonMartell\Extensions\Objects Inherited properties

This class has not inherited properties.

# NelsonMartell\Extensions\PropertyExtension

Provides extension methods to handle class properties.

Extends Nothing
Implements Nothing
Uses Nothing
Since v1.0.0
Authors Nelson Martell <nelson6e65@gmail.com>

# \NelsonMartell\Extensions\PropertyExtension Constants

This class has not constants.

# \NelsonMartell\Extensions\PropertyExtension Methods

ensureIsDefined ( ) static


Ensures that the property is defined in the specified class.

public static function ensureIsDefined( string $property, string $class, boolean $includeMagic = false ) : string
Parameter Type(s) Description
$property string
$class string
$includeMagic optional boolean
See also \NelsonMartell\Extensions\PropertyExtension::ensureIsValidName()

ensureIsValidName ( ) static


Ensures that a string is a valid property name.

public static function ensureIsValidName( string $name ) : string
Parameter Type(s) Description
$name string Property name to be ensured.
See also \NelsonMartell\Extensions\Text::ensureIsValidVarName()

# \NelsonMartell\Extensions\PropertyExtension Inherited methods

This class has not inherited methods.

# \NelsonMartell\Extensions\PropertyExtension Properties

This class has not properties.

# \NelsonMartell\Extensions\PropertyExtension Inherited properties

This class has not inherited properties.

# NelsonMartell\Extensions\Text

Provides extension methods to handle strings.

This class is based on \Cake\Utility\Text of CakePHP(tm) class.

Extends Nothing
Implements NelsonMartell\IComparer
Uses Nothing
Since v0.7.0
v1.0.0: Remove \Cake\Utility\Text dependency.
Authors Nelson Martell <nelson6e65@gmail.com>
See also \Cake\Utility\Text::insert()
http://book.cakephp.org/3.0/en/core-libraries/text.html (opens new window)

# \NelsonMartell\Extensions\Text Constants

This class has not constants.

# \NelsonMartell\Extensions\Text Methods

camelize ( ) static


Returns the input lower_case_delimited_string as a CamelCasedString.

public static function camelize( string $string, string $delimiter = '_' ) : string
Parameter Type(s) Description
$string string String to camelize
$delimiter optional string the delimiter in the input string
See also https://book.cakephp.org/3.0/en/core-libraries/inflector.html#creating-camelcase-and-under-scored-forms (opens new window)

Returns:

CamelizedStringLikeThis.

cleanInsert ( ) static


Cleans up a Text::insert() formatted string with given $options depending on the 'clean' key in $options. The default method used is text but html is also available. The goal of this function is to replace all whitespace and unneeded markup around placeholders that did not get replaced by Text::insert().

public static function cleanInsert( string $str, array $options ) : string
Parameter Type(s) Description
$str string String to clean.
$options array Options list.
See also \Cake\Utility\Text::insert()

compare ( ) static


Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.

public static function compare( mixed|string $left, mixed|string $right ) : integer|null
Parameter Type(s) Description
$left mixed
string
Object to which the relative position will be determined.
$right mixed
string
The second object to compare.

Description:

This methods is specific for the case when one of them are string. In other case, will fallback to Objects::compare().You should use it directly instead of this method as comparation function forusort()`.

Since v1.0.0
See also \NelsonMartell\Extensions\Objects::compare()

delimit ( ) static


Expects a CamelCasedInputString, and produces a lower_case_delimited_string

public static function delimit( string $string, string $delimiter = '_' ) : string
Parameter Type(s) Description
$string string String to delimit
$delimiter optional string the character to use as a delimiter

Returns:

delimited string

ensureIsNotEmpty ( ) static


Ensures that given string is not empty.

public static function ensureIsNotEmpty( string $string ) : string
Parameter Type(s) Description
$string string String to validate.

Returns:

Same string given, but ensured that is not empty.

ensureIsNotNull ( ) static


Ensures that object given is not null. If is null, throws and exception.

public static function ensureIsNotNull( mixed $obj ) : mixed
Parameter Type(s) Description
$obj mixed Object to validate

Returns:

Same object

ensureIsNotWhiteSpaces ( ) static


Ensures that given string is not empty or whitespaces.

public static function ensureIsNotWhiteSpaces( string $string ) : string
Parameter Type(s) Description
$string string String to validate.
See also \trim()

Returns:

Same string given, but ensured that is not whitespaces.

ensureIsString ( ) static


Ensures that object given is an string. Else, thows an exception

public static function ensureIsString( mixed $obj ) : string
Parameter Type(s) Description
$obj mixed Object to validate.

Returns:

Same object given, but ensured that is an string.

ensureIsValidVarName ( ) static


Ensures that an string follows the PHP variables naming convention.

public static function ensureIsValidVarName( string $string ) : string
Parameter Type(s) Description
$string string String to be ensured.
See also \NelsonMartell\Extensions\PropertyExtension::ensureIsValidName()

format ( ) static


Replaces format elements in a string with the string representation of an object matching the list of arguments specified. You can give as many params as you need, or an array with values.

public static function format( string $format, mixed $args ) : string
Parameter Type(s) Description
$format string An string containing variable placeholders to be replaced. If you provide name placeholders, you must pass the target array as
$args mixed

Description:

##Usage Using numbers as placeholders (encloses between { and }), you can get the matching string representation of each object given. Use {0} for the fist object, {1} for the second, and so on:

$format = '{0} is {1} years old, and have {2} cats.';
echo Text::format($format, 'Bob', 65, 101); // 'Bob is 65 years old, and have 101 cats.'

You can also use an array to give objects values:

$format = '{0} is {1} years old, and have {2} cats.';
$data   = ['Bob', 65, 101];
echo Text::format($format, $data); // 'Bob is 65 years old, and have 101 cats.'

This is specially useful to be able to use non-numeric placeholders (named placeholders):

$format = '{name} is {age} years old, and have {n} cats.';
$data = ['name' => 'Bob', 'n' => 101, 'age' => 65];
echo Text::format($format, $data); // 'Bob is 65 years old, and have 101 cats.'

For numeric placeholders, yo can convert the array into a list of arguments.

$format = '{0} is {1} years old, and have {2} cats.';
$data   = ['Bob', 65, 101];
echo Text::format($format, ...$data); // 'Bob is 65 years old, and have 101 cats.'

Note: If objects are not convertible to string, it will throws and catchable exception (InvalidArgumentException).

Authors Nelson Martell <nelson6e65@gmail.com>

humanize ( ) static


Returns the input lower_case_delimited_string as 'A Human Readable String'.

public static function humanize( string $string, string $delimiter = '_' ) : string
Parameter Type(s) Description
$string string String to be humanized
$delimiter optional string the character to replace with a space

Description:

(Underscores are replaced by spaces and capitalized following words.)

See also https://book.cakephp.org/3.0/en/core-libraries/inflector.html#creating-human-readable-forms (opens new window)

Returns:

Human-readable string

insert ( ) static


Replaces variable placeholders inside a $str with any given $data. Each key in the $data array corresponds to a variable placeholder name in $str.

public static function insert( string $str, array $data, array $options = array() ) : string
Parameter Type(s) Description
$str string A string containing variable placeholders
$data array A key => val array where each key stands for a placeholder variable name to be replaced with val
$options optional array An array of options, see description above

Description:

Example:

Text::insert(':name is :age years old.', ['name' => 'Bob', 'age' => '65']);

Returns: Bob is 65 years old.

Available $options are:

  • before: The character or string in front of the name of the variable placeholder (Defaults to :)
  • after: The character or string after the name of the variable placeholder (Defaults to null)
  • escape: The character or string used to escape the before character / string (Defaults to \)
  • format: A regex to use for matching variable placeholders. Default is: /(?<!\\)\:%s/ (Overwrites before, after, breaks escape / clean)
  • clean: A boolean or array with instructions for Text::cleanInsert

tokenize ( ) static


Tokenizes a string using $separator, ignoring any instance of $separator that appears between $leftBound and $rightBound.

public static function tokenize( string $data, string $separator = ',', string $leftBound = '(', string $rightBound = ')' ) : array&lt;mixed,string&gt;
Parameter Type(s) Description
$data string The data to tokenize.
$separator optional string The token to split the data on.
$leftBound optional string The left boundary to ignore separators in.
$rightBound optional string The right boundary to ignore separators in.
Since v1.0.0: Copied from https://github.com/cakephp/utility

Returns:

Array of tokens in $data.

underscore ( ) static


Returns the input CamelCasedString as an underscored_string.

public static function underscore( string $string ) : string
Parameter Type(s) Description
$string string CamelCasedString to be "underscorized"

Description:

Also replaces dashes with underscores

See also https://book.cakephp.org/3.0/en/core-libraries/inflector.html#creating-camelcase-and-under-scored-forms (opens new window)

Returns:

underscore_version of the input string

uuid ( ) static


Generate a random UUID version 4.

public static function uuid(  ) : string

Description:

Warning: This method should not be used as a random seed for any cryptographic operations. Instead you should use the openssl or mcrypt extensions.

It should also not be used to create identifiers that have security implications, such as 'unguessable' URL identifiers. Instead you should use Security::randomBytes() for that.

Since v1.0.0: Copied from https://github.com/cakephp/utility
See also https://www.ietf.org/rfc/rfc4122.txt

Returns:

RFC 4122 UUID

variable ( ) static


Returns camelBacked version of an underscored string.

public static function variable( string $string ) : string
Parameter Type(s) Description
$string string String to convert.
See also https://book.cakephp.org/3.0/en/core-libraries/inflector.html#creating-variable-names (opens new window)

Returns:

in variable form

# \NelsonMartell\Extensions\Text Inherited methods

This class has not inherited methods.

# \NelsonMartell\Extensions\Text Properties

This class has not properties.

# \NelsonMartell\Extensions\Text Inherited properties

This class has not inherited properties.

# NelsonMartell\StrictObject abstract

Base class that encapsulates strict properties and other basic features.

Extends Nothing
Implements NelsonMartell\IComparer
NelsonMartell\IConvertibleToString
NelsonMartell\IStrictPropertiesContainer
Uses NelsonMartell\PropertiesHandler
Since v0.1.1
v1.0.0: Made it abstract.
Authors Nelson Martell <nelson6e65@gmail.com>
See also \NelsonMartell\PropertiesHandler

# \NelsonMartell\StrictObject Constants

This class has not constants.

# \NelsonMartell\StrictObject Methods

__construct ( )


Constructor.

public function __construct(  ) : void

__toString ( ) final


Convierte esta instancia en su representación de cadena.

public function __toString(  ) : string

Description:

Para modificar el funcionamiento de esta función, debe reemplazarse la función ObjectClass::toString()

See also \NelsonMartell\StrictObject::toString()

compare ( ) static deprecated


Determines the relative position of the object on the left with respect to the one on the right.

public static function compare( mixed $left, mixed $right ) : integer|null
Parameter Type(s) Description
$left mixed Left object.
$right mixed Right object.

Description:

This method is compatible with core types and other types. You can implement NelsonMartell\IComparable in order to improve the beaviour for other classes.

This method can be used as sorting function for usort() function.

Notes:

  • Comparison is made in natural way if they are of the same type. If not, is used the PHP standard comparison.
  • If $left and $right are arrays, comparison is made by first by 'key' (as strings) and then by 'values' (using this method recursively).

Override: You can override this method to implement a contextual sorting behaviour for usort() function. If you only need to compare instances of your class with other objects, implement NelsonMartell\IComparable instead.

Deprecated Since v1.0.0: Use {@see Objects::compare()} instead.
See also \strnatcmp()
\usort()
\NelsonMartell\Extensions\Arrays::compare()
\NelsonMartell\IComparable
\NelsonMartell\IComparable::compareTo()
\NelsonMartell\IComparer::compare()
\NelsonMartell\Extensions\Numbers::compare()
\NelsonMartell\Extensions\Text::compare()
\NelsonMartell\Extensions\Objects::compare()

Returns:

Returns:

  • = 0 if $left is considered equivalent to $other;
  • > 0 if $left is considered greater than $other;
  • < 0 if $left is considered less than $other;
  • null if $left can't be compared to $other .

equals ( )


Indicates whether the specified object is equal to the current instance.

public function equals( mixed $other ) : boolean
Parameter Type(s) Description
$other mixed Another object to compare equality.

Returns:

Retuns default behaviour of ==. This method must be overridden.

toString ( )


Convierte la instancia actual en su representación de cadena.

public function toString(  ) : string

# \NelsonMartell\StrictObject Inherited methods

# \NelsonMartell\StrictObject Properties

This class has not properties.

# \NelsonMartell\StrictObject Inherited properties

This class has not inherited properties.

# NelsonMartell\Type final

Represents a PHP object type. Provides some properties and methods to describe some info about itself.

Extends NelsonMartell\StrictObject
Implements NelsonMartell\IComparer
NelsonMartell\IConvertibleToString
NelsonMartell\IEquatable
NelsonMartell\IMagicPropertiesContainer
NelsonMartell\IStrictPropertiesContainer
Uses NelsonMartell\PropertiesHandler
Since v0.1.1
Authors Nelson Martell <nelson6e65@gmail.com>

# \NelsonMartell\Type Constants

This class has not constants.

# \NelsonMartell\Type Methods

__construct ( )


Gets the type of specified $obj and collect some info about itself.

public function __construct( mixed|string $obj, boolean $searchName = false ) : void
Parameter Type(s) Description
$obj mixed
string
Target object or class|interface|trait name.
$searchName optional boolean Set this to true if $obj is a class name instead of an instance. This param is ignored if obj is not a string.
Since v1.0.0: Allow construct from a class name string.

canBeString ( )


Determines if instances of the underlying type can be converted to string.

public function canBeString(  ) : boolean

equals ( )


Indicates whether the specified object is equal to the current instance.

public function equals( mixed|\NelsonMartell\Type $other ) : boolean
Parameter Type(s) Description
$other mixed
\NelsonMartell\Type
Another object to compare equality.

Returns:

Returns always false if $other is not a Type.

getInterfaces ( )


Gets a list of all interfaces of the underlying type of this instance.

public function getInterfaces( boolean $reflection = false ) : array&lt;mixed,\ReflectionClass&gt;|array&lt;mixed,string&gt;|array
Parameter Type(s) Description
$reflection optional boolean If set to true, returns a list of interfaces as ReflectionClass (keyed by its names) instead of a list of names only (string).
Since v1.0.0

getMethods ( )


Gets the public|protected methods (ReflectionMethod) of the underlying type of this instance.

public function getMethods( integer $filters = \ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED ) : array&lt;mixed,\ReflectionMethod&gt;|array
Parameter Type(s) Description
$filters optional integer Filter the results to include only methods with certain attributes. Defaults to ReflectionMethod::IS_PUBLIC &#124; ReflectionMethod::IS_PROTECTED. Any combination of ReflectionMethod::IS_STATIC, ReflectionMethod::IS_PUBLIC, ReflectionMethod::IS_PROTECTED, ReflectionMethod::IS_PRIVATE, ReflectionMethod::IS_ABSTRACT and ReflectionMethod::IS_FINAL.
Since v1.0.0: Add $filters param.

getName ( )


Getter for $name property.

protected function getName(  ) : string
See also \NelsonMartell\Type::$name

getNamespace ( )


Getter for $namespace property.

public function getNamespace(  ) : string
See also \NelsonMartell\Type::$namespace

getProperties ( )


Gets the properties of underlying type of this instance

public function getProperties( integer $filters = \ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED ) : array&lt;mixed,\ReflectionProperty&gt;|array
Parameter Type(s) Description
$filters optional integer Filter the results to include only properties with certain attributes. Defaults to ReflectionMethod::IS_PUBLIC &#124; ReflectionMethod::IS_PROTECTED. Any combination of ReflectionMethod::IS_STATIC, ReflectionMethod::IS_PUBLIC, ReflectionMethod::IS_PROTECTED, ReflectionMethod::IS_PRIVATE.
Since v1.0.0: Replacement for Type::getVars()

getShortName ( )


Getter for $shortName property.

public function getShortName(  ) : string
See also \NelsonMartell\Type::$shortName

getTraits ( )


Gets a list of traits used by the underlying type of this instance.

public function getTraits( boolean $reflection = false, boolean $recursive = false ) : array
Parameter Type(s) Description
$reflection optional boolean If set to true, returns a list of interfaces as ReflectionClass (keyed by its names) instead of a list of names only (string).
$recursive optional boolean If set to true will get all traits used by parent classes and used traits.
Since v1.0.0

getVars ( ) deprecated


public function getVars( integer $filters = \ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED ) : array&lt;mixed,\ReflectionProperty&gt;|array
Parameter Type(s) Description
$filters optional integer
Deprecated Since v1.0.0: Use Type::getProperties() instead.
See also \NelsonMartell\Type::getProperties()

hasMethod ( )


Checks if the specified method is defined in the underlying type of this instance.

public function hasMethod( string $name ) : boolean
Parameter Type(s) Description
$name string

hasProperty ( )


Checks if the specified property is defined in the underlying type of this instance.

public function hasProperty( string $name, boolean $recursive = true, boolean $includeMagic = false ) : boolean
Parameter Type(s) Description
$name string Name of property.
$recursive optional boolean Indicates if search for inherithed properties. Default: true.
$includeMagic optional boolean Include check for properties in class DocBlock definition.

Description:

Unlike property_exists() function, this method returns false for dynamic attributes of an object.

This method is case-sensitive.

Since v1.0.0
See also \ReflectionClass::hasProperty()
\property_exists()

is ( )


Detects if all object are from the underlying type.

public function is( array $args ) : boolean
Parameter Type(s) Description
$args array List of object to check type.

Description:

  • Usage:
$var1 = 'Hola, mundo';
$allAreString = typeof((string) '')->isIn($var1, 1, 34); // false
$allAreString = typeof((string) '')->isIn($var1, '1', '34'); // true

Also works with 1st dimention of arrays:

$vars = ['Hola, mundo', '1', '34'];
$allAreString = typeof((string) '')->isIn($vars); // true
Since v1.0.0
See also \NelsonMartell\typeof()
\NelsonMartell\Type::isIn()

isCustom ( )


Determines if the underlying type of this instance is a custom class.

public function isCustom(  ) : boolean

Returns:

true, if the underlying type is a custom class; another case, false.

isIn ( )


Detects if at least one of the objects are from the underlying type.

public function isIn( array $args ) : boolean
Parameter Type(s) Description
$args array List of object to check type.

Description:

Usage:

$var1 = 'Hola, mundo';
$oneIsString = typeof((string) '')->isIn($var1, 1, 34); // true

Also works with 1st dimention of arrays:

$vars = ['Hola, mundo', 1, 34];
$oneIsString = typeof((string) '')->isIn($vars); // true
Since v1.0.0
See also \NelsonMartell\typeof()
\NelsonMartell\Type::is()

isNotNull ( ) deprecated


Determines if the underlying type is NOT null.

public function isNotNull(  ) : boolean
Deprecated Since v1.0.0: Use !Type::isNull() instead
See also \NelsonMartell\Type::isNull()

Returns:

true if this type is NOT null; other case, false.

isNull ( )


Determines if the underlying type is null.

public function isNull(  ) : boolean

Returns:

true if this type is null; other case, false.

isReferenceType ( )


Determines if the underlying type of this instance is ref type.

public function isReferenceType(  ) : boolean

isScalar ( )


Determines if the underlying type of this instance is scalar.

public function isScalar(  ) : boolean
See also \is_scalar()

isValueType ( )


Determines if the underlying type of this instance is value type.

public function isValueType(  ) : boolean

toString ( )


Converts the current instance to its string representation.

public function toString(  ) : string

# \NelsonMartell\Type Inherited methods

# \NelsonMartell\Type Properties

$name


public $name;

Types:

  • string

Description:

Gets the name of this Type. This property is read-only.

$shortName


public $shortName;

Types:

  • string

Description:

Gets the abbreviated name of class, in other words, without the namespace. This property is read-only.

$namespace


public $namespace;

Types:

  • string

Description:

Gets the namespace name of this class. If the underlying type is not a class, this property is set to '' (empty string). This property is read-only.

# \NelsonMartell\Type Inherited properties

This class has not inherited properties.

# NelsonMartell\Version final

Representa el número de versión de un programa o ensamblado, de la forma "1.2.3.4". Sólo siendo obligatorios el primer y segundo componente.

No se puede heredar esta clase.

Extends NelsonMartell\StrictObject
Implements NelsonMartell\IComparable
NelsonMartell\IComparer
NelsonMartell\IConvertibleToString
NelsonMartell\IEquatable
NelsonMartell\IMagicPropertiesContainer
NelsonMartell\IStrictPropertiesContainer
Uses NelsonMartell\PropertiesHandler
Since v0.1.1
Authors Nelson Martell <nelson6e65@gmail.com>

# \NelsonMartell\Version Constants

This class has not constants.

# \NelsonMartell\Version Methods

__construct ( )


Crea una nueva instancia con los números principal, secundario, de compilación (opcional) y revisión (opcional).

public function __construct( integer $major, integer $minor, integer|null|string|\NelsonMartell\VersionComponent $build = null, integer|null|string|\NelsonMartell\VersionComponent $revision = null ) : void
Parameter Type(s) Description
$major integer Componente principal
$minor integer Componente secundario
$build optional integer
null
string
\NelsonMartell\VersionComponent
Componente de compilación
$revision optional integer
null
string
\NelsonMartell\VersionComponent
Componente de revisión

Description:

Para comprobar si la versión es válida, usar el método isValid.

compareTo ( )


Determina la posición relativa de esta instancia con respecto al objeto especificado.

public function compareTo( mixed|string|\NelsonMartell\Version $other ) : integer|null
Parameter Type(s) Description
$other mixed
string
\NelsonMartell\Version
The other object to compare with. If this is of type string, it will try to convert to a Version object before the comparation.

Description:

For types different than Version (null, unparseable string and other value types) are considered lower than Version.

See also \NelsonMartell\Extensions\Objects::compare()

Returns:

  • = 0 if this instance is considered equivalent to $other;
    • > 0 si esta instancia se considera mayor a $other;
    • < 0 si esta instancia se considera menor a $other.
    • null if this instance can't be compared against $other .

equals ( )


Indicates whether the specified object is equal to the current instance.

public function equals( mixed|\NelsonMartell\Version $other ) : boolean
Parameter Type(s) Description
$other mixed
\NelsonMartell\Version
The other object to compare with.

getBuild ( )


Getter for build property.

protected function getBuild(  ) : \NelsonMartell\VersionComponent
See also \NelsonMartell\Version::$build

getMajor ( )


Getter for major property.

protected function getMajor(  ) : integer
See also \NelsonMartell\Version::$major

getMinor ( )


Getter for minor property.

protected function getMinor(  ) : integer
See also \NelsonMartell\Version::$minor

getRevision ( )


Getter for revision property.

protected function getRevision(  ) : \NelsonMartell\VersionComponent
See also \NelsonMartell\Version::$revision

isValid ( )


Indica si la instancia actual es un número de versión válido.

public function isValid(  ) : boolean

Description:

Se considera válido si:

  1. major o minor es mayor a cero (0). No puede ser '0.0'.
  2. build y revision son nulos (no están definidos).
  3. build está definido pero revision no.
  4. Ambos están definidos, pero no poseen la parte de la cadena.
  5. Ambos están definidos, pero build no posee la parte de cadena.
  6. build está definido y tiene la cadena, pero revision no está definido.
  7. revision posee cadena, pero build no.

Returns:

Un valor que indica si la instancia actual es válida.

parse ( ) static


Convierte una cadena a su representación del tipo Version.

public static function parse( array|float|integer|string|\NelsonMartell\Version $value ) : \NelsonMartell\Version
Parameter Type(s) Description
$value array
float
integer
string
\NelsonMartell\Version
Objeto a convertir.

Returns:

Objeto convertido desde $value.

toString ( )


Convierte la instancia actual en su representación en cadena.

public function toString(  ) : string

Description:

Por defecto, si no están definidos los componentes de compilación y revisión, no se incluyen en la salida. Use el método isValid si quiere determinar si la versión es válida antes de devolver esta cadena.

See also \NelsonMartell\VersionComponent::isNull()
\NelsonMartell\Version::isValid()

Returns:

Representación de la versión en forma de cadena: 'major.minor[.build[.revision]]'

# \NelsonMartell\Version Inherited methods

# \NelsonMartell\Version Properties

$major


public $major;

Types:

  • integer

Description:

Obtiene el valor del componente principal del número de versión. Esta propiedad es de sólo lectura.

$minor


public $minor;

Types:

  • integer

Description:

Obtiene el valor del componente secundario del número de versión. Esta propiedad es de sólo lectura.

$build


public $build;

Types:

  • \NelsonMartell\VersionComponent

Description:

Obtiene el valor del componente de compilación del número de versión. Esta propiedad es de sólo lectura.

$revision


public $revision;

Types:

  • \NelsonMartell\VersionComponent

Description:

Obtiene el valor del componente de revisión del número de versión. Esta propiedad es de sólo lectura.

# \NelsonMartell\Version Inherited properties

This class has not inherited properties.

# NelsonMartell\VersionComponent

Representa un componente de un número de Version.

Extiende la clase IntString, pero restringe los valores que puede tomar.

Extends \
Implements NelsonMartell\IEquatable
Uses Nothing
Since v0.1.1
Authors Nelson Martell <nelson6e65@gmail.com>

# \NelsonMartell\VersionComponent Constants

This class has not constants.

# \NelsonMartell\VersionComponent Methods

__construct ( )


public function __construct( integer|null $intValue = null, null|string $stringValue = null ) : void
Parameter Type(s) Description
$intValue optional integer
null
$stringValue optional null
string

compareTo ( )


public function compareTo( mixed $other ) : void
Parameter Type(s) Description
$other mixed

equals ( )


Indicates whether the specified object is equal to the current instance.

public function equals( mixed $other ) : boolean
Parameter Type(s) Description
$other mixed Another object to compare equality.

isDefault ( )


Determina si este componente tiene los valores predeterminados (0).

public function isDefault(  ) : boolean

isNotDefault ( )


Determina si este componente NO tiene los valores predeterminados.

public function isNotDefault(  ) : boolean

isNotNull ( )


Determina si esta instancia NO es nula.

public function isNotNull(  ) : boolean

isNull ( )


Determina si esta instancia es nula.

public function isNull(  ) : boolean

parse ( ) static


Converts the object to an instance of VersionComponent if compatible.

public static function parse( mixed $obj ) : \NelsonMartell\VersionComponent
Parameter Type(s) Description
$obj mixed Object to convert.

# \NelsonMartell\VersionComponent Inherited methods

This class has not inherited methods.

# \NelsonMartell\VersionComponent Properties

This class has not properties.

# \NelsonMartell\VersionComponent Inherited properties

This class has not inherited properties.


This document was automatically generated, from source code comments, using phpDocumentor (opens new window) with the VuePress template (opens new window).

Auto-generated at: 2022-05-03, 10:59 AM