Go to the source code of this file.
Functions |
| | _return_or_throw ($DefaultValue, $Field) |
| | get_field (&$Entity, $Field, $DefaultValue= '_throw_exception') |
| | get_fields (&$Entity, $Fields, $DefaultValue= '_throw_exception') |
| | is_field_set (&$Entity, $Field) |
| | get_field_ex (&$ArrayOfEntities, $Field, $DefaultValue= '_throw_exception') |
| | array_filter_ex (&$ArrayOfEntities, $Condition= '1==1') |
| | get_field_cond (&$ArrayOfEntities, $Field, $Condition= '1==1', $DefaultValue= '_throw_exception') |
| | array_sum_cond (&$Array, $Field=false, $Condition= '1==1') |
| | set_field (&$Entity, $Field, $Value) |
| | append_to_field (&$Entity, $Field, $Value) |
| | implode_ex ($Str, &$Arr, $Field) |
| | extend (&$Destination, $Source) |
| | array_sum_ex (&$Array, $Field=false) |
| | get_dummie (&$Entity) |
| | remove_fields (&$Entity, $Fields) |
| | make_array (&$Scalar) |
| | make_hash_by_field (&$Array, $Field) |
| | vectorize_by_field (&$Array, $Field) |
| | get_record_by_field (&$Array, $Field, $Value, $DefaultValue= '_throw_exception') |
Function Documentation
| _return_or_throw |
( |
|
$DefaultValue, |
|
|
|
$Field |
|
) |
| |
Function returns value or throws exception.
- Parameters
-
| $DefaultValue | - Default value. |
| $Field | - Field/key. |
- Returns
- Default value.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 42 of file functional_programming.php.
{
if( $DefaultValue === '_throw_exception' )
{
throw( new Exception( "Key '$Field' does not exists" ) );
}
else
{
return( $DefaultValue );
}
}
| append_to_field |
( |
& |
$Entity, |
|
|
|
$Field, |
|
|
|
$Value |
|
) |
| |
Function appends value.
- Parameters
-
| $Entity | - Object or array. |
| $Field | - Field/key. |
| $Value | - Value to be set. |
- Returns
- Object/array.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 513 of file functional_programming.php.
{
try
{
{
}
if( is_object( $Entity ) )
{
array_push( $Entity->$Field , $Value );
}
if( is_array( $Entity ) )
{
array_push( $Entity[ $Field ] , $Value );
}
return( $Entity );
}
catch( Exception $e )
{
}
}
| array_filter_ex |
( |
& |
$ArrayOfEntities, |
|
|
|
$Condition = '1 == 1' |
|
) |
| |
Function filters array.
- Parameters
-
| $ArrayOfEntities | - Array of objects or arrays. |
| $Condition | - Record filtration condition. |
- Returns
- Array of values.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 295 of file functional_programming.php.
{
try
{
$FilterFunction = create_function( '$Element' , "return( $Condition );" );
$FilteredArrayOfEntities = array_filter( $ArrayOfEntities , $FilterFunction );
return( $FilteredArrayOfEntities );
}
catch( Exception $e )
{
}
}
| array_sum_cond |
( |
& |
$Array, |
|
|
|
$Field = false, |
|
|
|
$Condition = '1 == 1' |
|
) |
| |
Function sum all array's elements.
- Parameters
-
| $Array | - Array with elements. |
| $Field | - Field to sum. |
| $Condition | - Record filtration condition. |
- Returns
- Sum.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 397 of file functional_programming.php.
{
try
{
if( count( $Array ) )
{
$Keys = array_keys( $Array );
if( is_array( $Array[ $Keys[ 0 ] ] ) )
{
$Sum = 0;
foreach( $Array as $i => $Element )
{
}
return( $Sum );
}
}
if( $Field !== false )
{
}
return( array_sum( $Array ) );
}
catch( Exception $e )
{
}
}
| array_sum_ex |
( |
& |
$Array, |
|
|
|
$Field = false |
|
) |
| |
Function sum all array's elements.
- Parameters
-
| $Array | - Array with elements. |
| $Field | - Field to sum. |
- Returns
- - Sum.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 656 of file functional_programming.php.
{
try
{
if( $Field !== false )
{
}
else
{
$Array2 = $Array;
}
return( array_sum( $Array2 ) );
}
catch( Exception $e )
{
}
}
| extend |
( |
& |
$Destination, |
|
|
|
$Source |
|
) |
| |
Function adds fields/values in the object/array.
- Parameters
-
| $Destination | - Changing object. |
| $Source | - Data to add. |
- Returns
- - Object/array.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 608 of file functional_programming.php.
{
try
{
if( $Source === false )
{
return( $Destination );
}
foreach( $Source as $k => $v )
{
$Destination =
set_field( $Destination , $k , $v );
}
return( $Destination );
}
catch( Exception $e )
{
}
}
Function creates dummie object or empty array.
- Parameters
-
- Returns
- - Array or object.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 699 of file functional_programming.php.
{
try
{
if( is_array( $Entity ) )
{
return( array() );
}
elseif( is_object( $Entity ) )
{
return( new stdClass() );
}
else
{
throw( new Exception( "Illegal data type : ".gettype( $Entity ) ) );
}
}
catch( Exception $e )
{
}
}
| get_field |
( |
& |
$Entity, |
|
|
|
$Field, |
|
|
|
$DefaultValue = '_throw_exception' |
|
) |
| |
Function returns value from array/object.
- Parameters
-
| $Entity | - Object or array. |
| $Field | - Field/key. |
| $DefaultValue | - Default value. |
- Returns
- Value.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 84 of file functional_programming.php.
{
try
{
if( is_object( $Entity ) )
{
if( property_exists( $Entity , $Field ) )
{
return( $Entity->$Field );
}
}
if( is_array( $Entity ) )
{
if( array_key_exists( $Field , $Entity ) )
{
return( $Entity[ $Field ] );
}
}
throw( new Exception( "Illegal value was passed" ) );
}
catch( Exception $e )
{
}
}
| get_field_cond |
( |
& |
$ArrayOfEntities, |
|
|
|
$Field, |
|
|
|
$Condition = '1 == 1', |
|
|
|
$DefaultValue = '_throw_exception' |
|
) |
| |
Function returns values from array of arrays/objects.
- Parameters
-
| $ArrayOfEntities | - Array of objects or arrays. |
| $Field | - Field/key. |
| $Condition | - Record filtration condition. |
| $DefaultValue | - Default value. |
- Returns
- Array of values.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 345 of file functional_programming.php.
{
try
{
$RetValues = array();
$FilteredArrayOfEntities =
array_filter_ex( $ArrayOfEntities , $Condition );
foreach( $FilteredArrayOfEntities as $k => $v )
{
$RetValues [] =
get_field( $v , $Field , $DefaultValue );
}
return( $RetValues );
}
catch( Exception $e )
{
}
}
| get_field_ex |
( |
& |
$ArrayOfEntities, |
|
|
|
$Field, |
|
|
|
$DefaultValue = '_throw_exception' |
|
) |
| |
Function returns value from array of arrays/objects.
- Parameters
-
| $ArrayOfEntities | - Array of objects or arrays. |
| $Field | - Field/key. |
| $DefaultValue | - Default value. |
- Returns
- Array of values.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 250 of file functional_programming.php.
{
try
{
$RetValues = array();
foreach( $ArrayOfEntities as $k => $v )
{
$RetValues [] =
get_field( $v , $Field , $DefaultValue );
}
return( $RetValues );
}
catch( Exception $e )
{
}
}
| get_fields |
( |
& |
$Entity, |
|
|
|
$Fields, |
|
|
|
$DefaultValue = '_throw_exception' |
|
) |
| |
Function returns values from array/object.
- Parameters
-
| $Entity | - Object or array. |
| $Fields | - Fields/keys. |
| $DefaultValue | - Default value. |
- Returns
- Value.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 146 of file functional_programming.php.
{
try
{
$Values = array();
$Fields = explode( ',' , $Fields );
foreach( $Fields as $i => $Field )
{
$Values [] =
get_field( $Entity , $Field , $DefaultValue );
}
return( $Values );
}
catch( Exception $e )
{
}
}
| get_record_by_field |
( |
& |
$Array, |
|
|
|
$Field, |
|
|
|
$Value, |
|
|
|
$DefaultValue = '_throw_exception' |
|
) |
| |
Function returns record.
- Parameters
-
| $Array | - Array of entities. |
| $Field | - Field name. |
| $Value | - Value. |
| $DefaultValue | - Default value. |
- Returns
- Record.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 947 of file functional_programming.php.
{
try
{
foreach( $Array as $i => $Element )
{
if(
get_field( $Element , $Field , $DefaultValue ) == $Value )
{
return( $Element );
}
}
return( false );
}
catch( Exception $e )
{
}
}
| implode_ex |
( |
|
$Str, |
|
|
& |
$Arr, |
|
|
|
$Field |
|
) |
| |
Function joins object's/array's fields.
- Parameters
-
| $Str | - Joining string. |
| $Arr | - Array of objects/arrays. |
| $Field | - Joining field. |
- Returns
- - Object/array.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 570 of file functional_programming.php.
{
try
{
}
catch( Exception $e )
{
}
}
| is_field_set |
( |
& |
$Entity, |
|
|
|
$Field |
|
) |
| |
Function validate field's existance.
- Parameters
-
| $Entity | - Object or array. |
| $Field | - Field/key. |
- Returns
- true if exists, false otherwise.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 192 of file functional_programming.php.
{
try
{
if( is_object( $Entity ) )
{
if( property_exists( $Entity , $Field ) )
{
return( true );
}
}
if( is_array( $Entity ) )
{
if( isset( $Entity[ $Field ] ) )
{
return( true );
}
}
return( false );
}
catch( Exception $e )
{
}
}
Function creates array using scalar.
- Parameters
-
- Returns
- - Array.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 797 of file functional_programming.php.
{
try
{
if( is_array( $Scalar ) || is_object( $Scalar ) )
{
return( $Scalar );
}
else
{
return( array( $Scalar ) );
}
}
catch( Exception $e )
{
}
}
| make_hash_by_field |
( |
& |
$Array, |
|
|
|
$Field |
|
) |
| |
Function creates hash.
- Parameters
-
| $Array | - Array of entities. |
| $Field | - Field name. |
- Returns
- - Hash.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 842 of file functional_programming.php.
{
try
{
$Return = array();
foreach( $Array as $k => $v )
{
}
return( $Return );
}
catch( Exception $e )
{
}
}
| remove_fields |
( |
& |
$Entity, |
|
|
|
$Fields |
|
) |
| |
Function removes specified array's elements.
- Parameters
-
| $Entity | - Object or array. |
| $Fields | - Array of fields. |
- Returns
- - Changed object or array.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 748 of file functional_programming.php.
{
try
{
if( is_array( $Fields ) === false )
{
$Fields = array( $Fields );
}
foreach( $Entity as $Field => $Value )
{
if( array_search( $Field , $Fields ) === false )
{
set_field( $ChangedEntity , $Field , $Value );
}
}
return( $Entity = $ChangedEntity );
}
catch( Exception $e )
{
}
}
| set_field |
( |
& |
$Entity, |
|
|
|
$Field, |
|
|
|
$Value |
|
) |
| |
Function sets value from array/object.
- Parameters
-
| $Entity | - Object or array. |
| $Field | - Field/key. |
| $Value | - Value to be set. |
- Returns
- Object/array.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 459 of file functional_programming.php.
{
try
{
if( is_object( $Entity ) )
{
$Entity->$Field = $Value;
return( $Entity );
}
if( is_array( $Entity ) )
{
$Entity[ $Field ] = $Value;
return( $Entity );
}
return( $Entity );
}
catch( Exception $e )
{
}
}
| vectorize_by_field |
( |
& |
$Array, |
|
|
|
$Field |
|
) |
| |
Function vectorises array.
- Parameters
-
| $Array | - Array of entities. |
| $Field | - Field name. |
- Returns
- - Hash.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 887 of file functional_programming.php.
{
try
{
$Return = array();
foreach( $Array as $k => $v )
{
if( isset( $Return[ $Key ] ) === false )
{
$Return[ $Key ] = array();
}
$Return[ $Key ][] = $v;
}
return( $Return );
}
catch( Exception $e )
{
}
}