\Functional

Wrapper for Yandex Metrika REST API.

Summary

Methods
Properties
Constants
get_field()
set_field()
get_fields()
set_fields_in_objects()
sum_fields()
transform()
filter()
replace_fields()
set_children()
set_child()
expand_records_with()
sort_records()
sort_records_desc()
field_exists()
No public properties found
No constants found
set_existing_field()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

get_field()

get_field(  $Record,   $Field,   $Recursive = true) 

Method returns field of the object/array.

Parameters

$Record
$Field
$Recursive

set_field()

set_field(  $Record,   $Field,   $Value) 

Method sets field of the object/array.

Parameters

$Record
$Field
$Value

get_fields()

get_fields(  $Data,   $Field,   $Recursive = true) 

Method fetches all fields from objects/arrays of an array.

Parameters

$Data
$Field
$Recursive

set_fields_in_objects()

set_fields_in_objects(  $Objects,   $FieldName,   $Values) 

Method sets fields $FieldName in array of objects $Objects with $Values.

Parameters

$Objects
$FieldName
$Values

sum_fields()

sum_fields(  $Objects,   $FieldName) : mixed

Method sums fields in an array of objects.

Parameters

$Objects
$FieldName

Returns

mixed —

Sum of fields.

transform()

transform(  $Objects,   $Transformer) 

Method transforms objects in array.

Parameters

$Objects
$Transformer

filter()

filter(array  $Objects, string  $Field, string  $Operation = '==', mixed  $Value = false, boolean  $Recursive = true) : array

Method filters objects in array.

Parameters

array $Objects
  • List of records to be filtered.
string $Field
  • Filter field.
string $Operation
  • Filtration operation.
mixed $Value
  • Filtration value.
boolean $Recursive
  • Recursive mode.

Returns

array —
  • List of filtered records.

replace_fields()

replace_fields(array  $Objects, string  $FieldFrom, string  $FieldTo) 

Method replaces one field toanother in array of records.

Parameters

array $Objects
  • Objects tobe processed.
string $FieldFrom
  • Field name to be replaced.
string $FieldTo
  • Field name to be added.

set_children()

set_children(string  $Field, array  $Objects, string  $ObjectField, array  $Records, string  $RecordField) : array

Method adds nested records to the original record of objects.

Parameters

string $Field
  • Field name.
array $Objects
  • The original record of objects.
string $ObjectField
  • Filtering field.
array $Records
  • List of nested records.
string $RecordField
  • Filtering field.

Returns

array —

List of tramsformed records.

set_child()

set_child(string  $Field, array  $Objects, string  $ObjectField, array  $Records, string  $RecordField) : array

Method adds nested record to the original record of objects.

Parameters

string $Field
  • Field name.
array $Objects
  • The original record of objects.
string $ObjectField
  • Filtering field.
array $Records
  • List of nested records.
string $RecordField
  • Filtering field.

Returns

array —

List of tramsformed records.

expand_records_with()

expand_records_with(array  $Dest, string  $DestField, array  $Src, string  $SrcField) 

Method unites corresponding records.

Parameters

array $Dest
  • Destination array of records.
string $DestField
  • Field name.
array $Src
  • Source array of records.
string $SrcField
  • Field name.

sort_records()

sort_records(array  $Objects, string  $Field) 

Method sorts records by the specified field.

Parameters

array $Objects
  • Records to be sorted.
string $Field
  • Field name.

sort_records_desc()

sort_records_desc(array  $Objects, string  $Field) 

Method sorts records by the specified field.

Parameters

array $Objects
  • Records to be sorted.
string $Field
  • Field name.

field_exists()

field_exists(mixed  $Record, string  $Field, boolean  $Recursive = true) : boolean

Method returns field of the object/array.

Parameters

mixed $Record
  • Record to be analyzed.
string $Field
  • Field name.
boolean $Recursive
  • Do we need recursive descending.

Returns

boolean —

Does the field $Field exists or not.

set_existing_field()

set_existing_field(  $Record,   $Field,   $Value) 

Method sets existing field of the object/array.

Parameters

$Record
$Field
$Value