public function range($val, $x, $y)
    {
        return $this->andX($this->gt($val, $x), $this->lt($val, $y));
    }

public function range ( $ val , $ x , $ y ) { return $ this -> andX ( $ this -> gt ( $ val , $ x ) , $ this -> lt ( $ val , $ y ) ) ; }

Creates an instance of range, with the given argument.

@param mixed $val Valued to be inspected by range values.
@param int   $x   Starting range value to be used.
@param int   $y   End point value to be used.

@return DoctrineExpr\Andx

Creates an instance of range with the given argument .


final public static function session_start()
    {
        if ( self::$started ) trigger_error('Session already started', E_USER_WARNING);

        self::$started = true;

        if ( isset($_COOKIE[session_name()]) ) {
            self::$id = $_COOKIE[session_name()];
        } else {
            self::$id = uniqid();

            $config = self::session_get_cookie_params();
            Cookie::setcookie(
                session_name(), self::$id,
                $config['lifetime'], $config['path'], $config['domain'],
                $config['secure'], $config['httponly']
            );
        }

        if ( !$savePath = session_save_path() ) $savePath = sys_get_temp_dir();
        if ( !is_dir($savePath) ) mkdir($savePath, 0777);

        self::$file = sprintf('%s/sess_%s', $savePath, self::$id);

        if (self::$handler) {
            self::$handler->open($savePath, session_name());
            self::$handler->read(self::$id);
        }

        if ( file_exists(self::$file) ) {
            $data = file_get_contents(self::$file);
            session_decode($data);
        }

        return true;
    }

final
public
static
function
session_start
(
)
{
if
(
self
::
$
started
)
trigger_error
(
'Session already started'
,
E_USER_WARNING
)
;
self
::
$
started
=
true
;
if
(
isset
(
$
_COOKIE
[
session_name
(
)
]
)
)
{
self
::
$
id
=
$
_COOKIE
[
session_name
(
)
]
;
}
else
{
self
::
$
id
=
uniqid
(
)
;
$
config
=
self
::
session_get_cookie_params
(
)
;
Cookie
::
setcookie
(
session_name
(
)
,
self
::
$
id
,
$
config
[
'lifetime'
]
,
$
config
[
'path'
]
,
$
config
[
'domain'
]
,
$
config
[
'secure'
]
,
$
config
[
'httponly'
]
)
;
}
if
(
!
$
savePath
=
session_save_path
(
)
)
$
savePath
=
sys_get_temp_dir
(
)
;
if
(
!
is_dir
(
$
savePath
)
)
mkdir
(
$
savePath
,
0777
)
;
self
::
$
file
=
sprintf
(
'%s/sess_%s'
,
$
savePath
,
self
::
$
id
)
;
if
(
self
::
$
handler
)
{
self
::
$
handler
->
open
(
$
savePath
,
session_name
(
)
)
;
self
::
$
handler
->
read
(
self
::
$
id
)
;
}
if
(
file_exists
(
self
::
$
file
)
)
{
$
data
=
file_get_contents
(
self
::
$
file
)
;
session_decode
(
$
data
)
;
}
return
true
;
}

Start new or resume existing session

@link http://www.php.net/manual/en/function.session-start.php


final public static function session_regenerate_id($delete_old_session = false)
    {
        if ( !self::$started ) return false;

        if ( $delete_old_session ) self::session_destroy();
        else {
            self::$started = null;
            self::$file = null;
            self::$id = null;
        }

        if ( isset($_COOKIE[session_name()]) ) unset($_COOKIE[session_name()]);
        return self::session_start();
    }

final public static function session_regenerate_id ( $ delete_old_session = false ) { if ( ! self :: $ started ) return false ; if ( $ delete_old_session ) self :: session_destroy ( ) ; else { self :: $ started = null ; self :: $ file = null ; self :: $ id = null ; } if ( isset ( $ _COOKIE [ session_name ( ) ] ) ) unset ( $ _COOKIE [ session_name ( ) ] ) ; return self :: session_start ( ) ; }

Update the current session id with a newly generated one

@link http://www.php.net/manual/en/function.session-regenerate-id.php

@param  boolean $delete_old_session (optional) Whether to delete the old associated session file or not.
@return boolean


final public static function session_write_close()
    {
        if ( !self::$started ) return;

        if (self::$handler) {
            self::$handler->write(self::$id, self::session_encode());
            self::$handler->close();
        }

        self::$started = false;
        file_put_contents(self::$file, self::session_encode());
    }

final public static function session_write_close ( ) { if ( ! self :: $ started ) return ; if ( self :: $ handler ) { self :: $ handler -> write ( self :: $ id , self :: session_encode ( ) ) ; self :: $ handler -> close ( ) ; } self :: $ started = false ; file_put_contents ( self :: $ file , self :: session_encode ( ) ) ; }

Write session data and end session

@link http://www.php.net/manual/en/function.session-write-close.php


final public static function session_unset()
    {
        if ( !isset($_SESSION) ) return false;

        foreach ($_SESSION as $key => $value) {
            unset($_SESSION[$key]);
        }
    }

final public static function session_unset ( ) { if ( ! isset ( $ _SESSION ) ) return false ; foreach ( $ _SESSION as $ key => $ value ) { unset ( $ _SESSION [ $ key ] ) ; } }

Free all session variables

@link http://www.php.net/manual/en/function.session-unset.php


final public static function session_destroy()
    {
        if ( !self::$started ) return false;
        self::reset();

        if ( file_exists(self::$file) ) unlink(self::$file);
        return true;
    }

final public static function session_destroy ( ) { if ( ! self :: $ started ) return false ; self :: reset ( ) ; if ( file_exists ( self :: $ file ) ) unlink ( self :: $ file ) ; return true ; }

Destroys all data registered to a session

@link http://www.php.net/manual/en/function.session-destroy.php

@return boolean


final public static function session_decode($data)
    {
        if ( !$values = unserialize($data) ) return false;
        foreach ($values as $key => $value) {
            $_SESSION[$key] = $value;
        }

        return true;
    }

final public static function session_decode ( $ data ) { if ( ! $ values = unserialize ( $ data ) ) return false ; foreach ( $ values as $ key => $ value ) { $ _SESSION [ $ key ] = $ value ; } return true ; }

Decodes session data from a session encoded string

@link http://www.php.net/manual/en/function.session-decode.php
@todo implement standard PHP session serailization

@param  string  $data The encoded data to be stored.
@return boolean


final public static function session_cache_expire($new_cache_expire = null)
    {
        if( !$new_cache_expire ) return (int) ini_get('session.cache_expire');
        ini_set('session.cache_expire', (int) $new_cache_expire);

        return (int) $new_cache_expire;
    }

final public static function session_cache_expire ( $ new_cache_expire = null ) { if ( ! $ new_cache_expire ) return ( int ) ini_get ( 'session.cache_expire' ) ; ini_set ( 'session.cache_expire' , ( int ) $ new_cache_expire ) ; return ( int ) $ new_cache_expire ; }

Return current cache expire

@todo review if this is working.
@link http://www.php.net/manual/en/function.session-cache-expire.php

@param  string $new_cache_expire (optional) If new_cache_expire is given, the current cache expire is replaced with new_cache_expire.
@return string Returns the current setting of session.cache_expire. The value returned should be read in minutes, defaults to 180.


public static function instance($refresh = false)
    {
        $className = get_called_class();
        if ($refresh || !isset(self::$_instances[$className])) {
            self::$_instances[$className] = \Reaction::create($className);
        }
        return self::$_instances[$className];
    }

public static function instance ( $ refresh = false ) { $ className = get_called_class ( ) ; if ( $ refresh || ! isset ( self :: $ _instances [ $ className ] ) ) { self :: $ _instances [ $ className ] = \ Reaction :: create ( $ className ) ; } return self :: $ _instances [ $ className ] ; }

Returns static class instance, which can be used to obtain meta information.
@param bool $refresh whether to re-create static instance even, if it is already cached.
@return static class instance.

Returns static class instance which can be used to obtain meta information .


protected function getModuleOptions()
    {
        $entitys = $this->moduleService->getAll(array(
            'pagination' => 'off'
        ));

        $options = array();

        foreach ($entitys as $entity) {
            $options[$entity->getModuleId()] = $entity->getModuleName();
        }

        return $options;
    }

protected function getModuleOptions ( ) { $ entitys = $ this -> moduleService -> getAll ( array ( 'pagination' => 'off' ) ) ; $ options = array ( ) ; foreach ( $ entitys as $ entity ) { $ options [ $ entity -> getModuleId ( ) ] = $ entity -> getModuleName ( ) ; } return $ options ; }

gets module options for select

@return NULL[]


public function getSize($which = null)
    {
        if (!empty($which)) {
            return (isset($this->_size[$which]) ? $this->_size[$which] : null);
        } else {
            return $this->_size;
        }
    }

public function getSize ( $ which = null ) { if ( ! empty ( $ which ) ) { return ( isset ( $ this -> _size [ $ which ] ) ? $ this -> _size [ $ which ] : null ) ; } else { return $ this -> _size ; } }

Get the matrix size

@param   string  $which
@return  int|array


public function setWalkFlag($flag, $auto_rewind = true)
    {
        $this->_walk_flag = $flag;
        if (true==$auto_rewind) {
            $this->rewindXY();
        }
        return $this;
    }

public function setWalkFlag ( $ flag , $ auto_rewind = true ) { $ this -> _walk_flag = $ flag ; if ( true == $ auto_rewind ) { $ this -> rewindXY ( ) ; } return $ this ; }

Define the object's walk flag

@param   int     $flag
@param   bool    $auto_rewind
@return  $this


public function setArrayFlag($flag, $auto_rewind = true)
    {
        $this->_array_flag = $flag;
        if (true==$auto_rewind) {
            $this->rewindXY();
        }
        return $this;
    }

public function setArrayFlag ( $ flag , $ auto_rewind = true ) { $ this -> _array_flag = $ flag ; if ( true == $ auto_rewind ) { $ this -> rewindXY ( ) ; } return $ this ; }

Define the object's array access flag

@param   int     $flag
@param   bool    $auto_rewind
@return  $this


public function setData(array $data = null)
    {
        $line_length = $column_length = 0;
        foreach ($data as $x=>$items) {
            if (!is_array($items)) {
                throw new InvalidArgumentException(
                    "Data parameter of matrix must be a 2 dimensional array (array of arrays)!"
                );
            }
            if (count($items)>$line_length) {
                $line_length = count($items) - 1;
            }
            foreach ($items as $subitems) {
                if (count($subitems)>$column_length) {
                    $column_length = count($subitems) - 1;
                }
            }
        }
        $this->_size = array(
            'x' => $line_length,
            'y' => $column_length,
            'c' => ($line_length * $column_length)
        );
        foreach ($data as $x=>$items) {
            $this->data[$x] = $this->_padLine($items);
        }
        $this->_cache = $this->data;
    }

Set the matrix contents

@param   array   $data
@return  void
@throws  InvalidArgumentException if `$data` is not a 2D array


public function get($index)
    {
        try {
            if (is_string($index)) {
                if ($this->getWalkFlag() & self::WALK_X) {
                    $ret = $this->getX($index);
                } elseif ($this->getWalkFlag() & self::WALK_Y) {
                    $ret = $this->getY($index);
                } else {
                    $ret = $this->getXY($index);
                }
            } else {
                $ret = $this->getInt($index);
            }
        } catch (InvalidArgumentException $e) {
            throw $e;
        } catch (OutOfRangeException $e) {
            throw $e;
        }
        return $ret;
    }

public function get ( $ index ) { try { if ( is_string ( $ index ) ) { if ( $ this -> getWalkFlag ( ) & self :: WALK_X ) { $ ret = $ this -> getX ( $ index ) ; } elseif ( $ this -> getWalkFlag ( ) & self :: WALK_Y ) { $ ret = $ this -> getY ( $ index ) ; } else { $ ret = $ this -> getXY ( $ index ) ; } } else { $ ret = $ this -> getInt ( $ index ) ; } } catch ( InvalidArgumentException $ e ) { throw $ e ; } catch ( OutOfRangeException $ e ) { throw $ e ; } return $ ret ; }

Get a cell value by index according to matrix's flags

@param   string|int     $index
@return  mixed|null
@throws  OutOfRangeException if the index is out of range
@throws  InvalidArgumentException if the argument is malformed
@see     self::getX()
@see     self::getY()
@see     self::getXY()
@see     self::getInt()

Get a cell value by index according to matrix s flags


public function set($index, $value)
    {
        try {
            if (is_string($index)) {
                if ($this->getWalkFlag() & self::WALK_X) {
                    $this->setX($index, $value);
                } elseif ($this->getWalkFlag() & self::WALK_Y) {
                    $this->setY($index, $value);
                } else {
                    $this->setXY($index, $value);
                }
            } else {
                $this->setInt($index, $value);
            }
        } catch (InvalidArgumentException $e) {
            throw $e;
        } catch (OutOfRangeException $e) {
            throw $e;
        }
        return $this;
    }

public function set ( $ index , $ value ) { try { if ( is_string ( $ index ) ) { if ( $ this -> getWalkFlag ( ) & self :: WALK_X ) { $ this -> setX ( $ index , $ value ) ; } elseif ( $ this -> getWalkFlag ( ) & self :: WALK_Y ) { $ this -> setY ( $ index , $ value ) ; } else { $ this -> setXY ( $ index , $ value ) ; } } else { $ this -> setInt ( $ index , $ value ) ; } } catch ( InvalidArgumentException $ e ) { throw $ e ; } catch ( OutOfRangeException $ e ) { throw $ e ; } return $ this ; }

Set a value by index according to matrix's flags

@param   string|int   $index
@param   mixed        $value
@return  $this
@throws  OutOfRangeException if the index is out of range
@throws  InvalidArgumentException if the argument is malformed
@see     self::setX()
@see     self::setY()
@see     self::setXY()
@see     self::setInt()

Set a value by index according to matrix s flags


public function rewind()
    {
        if ($this->getWalkFlag() & self::WALK_X) {
            return $this->rewindX();
        } elseif ($this->getWalkFlag() & self::WALK_Y) {
            return $this->rewindY();
        } else {
            return $this->rewindXY();
        }
    }

public function rewind ( ) { if ( $ this -> getWalkFlag ( ) & self :: WALK_X ) { return $ this -> rewindX ( ) ; } elseif ( $ this -> getWalkFlag ( ) & self :: WALK_Y ) { return $ this -> rewindY ( ) ; } else { return $ this -> rewindXY ( ) ; } }

Rewind a matrix according to its flag value

@return  $this
@see     self::rewindX()
@see     self::rewindY()
@see     self::rewindXY()


public function previous()
    {
        if ($this->getWalkFlag() & self::WALK_X) {
            return $this->previousX();
        } elseif ($this->getWalkFlag() & self::WALK_Y) {
            return $this->previousY();
        } else {
            return $this->previousXY();
        }
    }

public function previous ( ) { if ( $ this -> getWalkFlag ( ) & self :: WALK_X ) { return $ this -> previousX ( ) ; } elseif ( $ this -> getWalkFlag ( ) & self :: WALK_Y ) { return $ this -> previousY ( ) ; } else { return $ this -> previousXY ( ) ; } }

Go to previous index according to matrix's flag value

@return  $this
@see     self::previousX()
@see     self::previousY()
@see     self::previousXY()

Go to previous index according to matrix s flag value


public function previousX()
    {
        if ($this->previousXExists()) {
            $this->seekX($this->keyX()-1);
        } else {
            $this->x = null;
        }
        return $this;
    }

public function previousX ( ) { if ( $ this -> previousXExists ( ) ) { $ this -> seekX ( $ this -> keyX ( ) - 1 ) ; } else { $ this -> x = null ; } return $ this ; }

Seek to current `x` less 1

@return  $this


public function previousY()
    {
        if ($this->previousYExists()) {
            $this->seekY($this->keyY()-1);
        } else {
            $this->y = null;
        }
        return $this;
    }

public function previousY ( ) { if ( $ this -> previousYExists ( ) ) { $ this -> seekY ( $ this -> keyY ( ) - 1 ) ; } else { $ this -> y = null ; } return $ this ; }

Seek to current `y` less 1

@return  $this


public function previousXY()
    {
        if (($this->keyY()-1)>0) {
            $this->seekY($this->keyY()-1);
        } else {
            if (($this->keyX()-1)>0) {
                $this->rewindY();
                $this->seekX($this->keyX()-1);
            } else {
                $this->x = null;
                $this->y = null;
            }
        }
        return $this;
    }

public function previousXY ( ) { if ( ( $ this -> keyY ( ) - 1 ) > 0 ) { $ this -> seekY ( $ this -> keyY ( ) - 1 ) ; } else { if ( ( $ this -> keyX ( ) - 1 ) > 0 ) { $ this -> rewindY ( ) ; $ this -> seekX ( $ this -> keyX ( ) - 1 ) ; } else { $ this -> x = null ; $ this -> y = null ; } } return $ this ; }


public function next()
    {
        if ($this->getWalkFlag() & self::WALK_X) {
            return $this->nextX();
        } elseif ($this->getWalkFlag() & self::WALK_Y) {
            return $this->nextY();
        } else {
            return $this->nextXY();
        }
    }

public function next ( ) { if ( $ this -> getWalkFlag ( ) & self :: WALK_X ) { return $ this -> nextX ( ) ; } elseif ( $ this -> getWalkFlag ( ) & self :: WALK_Y ) { return $ this -> nextY ( ) ; } else { return $ this -> nextXY ( ) ; } }

Go to next index according to matrix's flag value

@return  $this
@see     self::nextX()
@see     self::nextY()
@see     self::nextXY()

Go to next index according to matrix s flag value


public function nextX()
    {
        if ($this->nextXExists()) {
            $this->seekX($this->keyX()+1);
        } else {
            $this->x = null;
        }
        return $this;
    }

public function nextX ( ) { if ( $ this -> nextXExists ( ) ) { $ this -> seekX ( $ this -> keyX ( ) + 1 ) ; } else { $ this -> x = null ; } return $ this ; }

Seek to current `x` plus 1

@return  $this


public function nextY()
    {
        if ($this->nextYExists()) {
            $this->seekY($this->keyY()+1);
        } else {
            $this->y = null;
        }
        return $this;
    }

public function nextY ( ) { if ( $ this -> nextYExists ( ) ) { $ this -> seekY ( $ this -> keyY ( ) + 1 ) ; } else { $ this -> y = null ; } return $ this ; }

Seek to current `y` plus 1

@return  $this


public function nextXY()
    {
        if (($this->keyY()+1)<=$this->countY()) {
            $this->seekY($this->keyY()+1);
        } else {
            if (($this->keyX()+1)<=$this->countX()) {
                $this->rewindY();
                $this->seekX($this->keyX()+1);
            } else {
                $this->x = null;
                $this->y = null;
            }
        }
        return $this;
    }

public function nextXY ( ) { if ( ( $ this -> keyY ( ) + 1 ) <= $ this -> countY ( ) ) { $ this -> seekY ( $ this -> keyY ( ) + 1 ) ; } else { if ( ( $ this -> keyX ( ) + 1 ) <= $ this -> countX ( ) ) { $ this -> rewindY ( ) ; $ this -> seekX ( $ this -> keyX ( ) + 1 ) ; } else { $ this -> x = null ; $ this -> y = null ; } } return $ this ; }


public function seek($index)
    {
        try {
            if ($this->getWalkFlag() & self::WALK_X) {
                return $this->seekX($index);
            } elseif ($this->getWalkFlag() & self::WALK_Y) {
                return $this->seekY($index);
            } else {
                return $this->seekXY($index);
            }
        } catch (InvalidArgumentException $e) {
            throw $e;
        } catch (OutOfRangeException $e) {
            throw $e;
        }
    }

public function seek ( $ index ) { try { if ( $ this -> getWalkFlag ( ) & self :: WALK_X ) { return $ this -> seekX ( $ index ) ; } elseif ( $ this -> getWalkFlag ( ) & self :: WALK_Y ) { return $ this -> seekY ( $ index ) ; } else { return $ this -> seekXY ( $ index ) ; } } catch ( InvalidArgumentException $ e ) { throw $ e ; } catch ( OutOfRangeException $ e ) { throw $ e ; } }

Seek to index according to matrix's flag value

@param   string  $index
@return  $this
@throws  OutOfRangeException if the index is out of range
@throws  InvalidArgumentException if the argument is malformed

Seek to index according to matrix s flag value


public function current()
    {
        if ($this->getWalkFlag() & self::WALK_X) {
            return $this->currentX();
        } elseif ($this->getWalkFlag() & self::WALK_Y) {
            return $this->currentY();
        } else {
            return $this->currentXY();
        }
    }

public function current ( ) { if ( $ this -> getWalkFlag ( ) & self :: WALK_X ) { return $ this -> currentX ( ) ; } elseif ( $ this -> getWalkFlag ( ) & self :: WALK_Y ) { return $ this -> currentY ( ) ; } else { return $ this -> currentXY ( ) ; } }

Get current value according to matrix's flag value

@return  mixed|null
@see     self::currentX()
@see     self::currentY()
@see     self::currentXY()

Get current value according to matrix s flag value


public function key()
    {
        if ($this->getWalkFlag() & self::WALK_X) {
            return $this->keyX();
        } elseif ($this->getWalkFlag() & self::WALK_Y) {
            return $this->keyY();
        } else {
            return $this->keyXY();
        }
    }

public function key ( ) { if ( $ this -> getWalkFlag ( ) & self :: WALK_X ) { return $ this -> keyX ( ) ; } elseif ( $ this -> getWalkFlag ( ) & self :: WALK_Y ) { return $ this -> keyY ( ) ; } else { return $ this -> keyXY ( ) ; } }

Get current index according to matrix's flag value

@return  string|null
@see     self::keyX()
@see     self::keyY()
@see     self::keyXY()

Get current index according to matrix s flag value


public function valid()
    {
        if ($this->getWalkFlag() & self::WALK_X) {
            return $this->validX();
        } elseif ($this->getWalkFlag() & self::WALK_Y) {
            return $this->validY();
        } else {
            return $this->validXY();
        }
    }

public function valid ( ) { if ( $ this -> getWalkFlag ( ) & self :: WALK_X ) { return $ this -> validX ( ) ; } elseif ( $ this -> getWalkFlag ( ) & self :: WALK_Y ) { return $ this -> validY ( ) ; } else { return $ this -> validXY ( ) ; } }

Test if current value is valid according to matrix's flag value

@return  bool
@see     self::validX()
@see     self::validY()
@see     self::validXY()

Test if current value is valid according to matrix s flag value


public function validX()
    {
        return (bool) (!is_null($this->keyX()) && isset($this->data[$this->keyX(true)]));
    }

public function validX ( ) { return ( bool ) ( ! is_null ( $ this -> keyX ( ) ) && isset ( $ this -> data [ $ this -> keyX ( true ) ] ) ) ; }

Test if current `x` line is valid

@return  bool


public function validY()
    {
        return (bool) ($this->validX() && !is_null($this->keyY()) && isset($this->data[$this->keyX(true)][$this->keyY(true)]));
    }

public function validY ( ) { return ( bool ) ( $ this -> validX ( ) && ! is_null ( $ this -> keyY ( ) ) && isset ( $ this -> data [ $ this -> keyX ( true ) ] [ $ this -> keyY ( true ) ] ) ) ; }

Test if current `y` column is valid

@return  bool


public function count()
    {
        if ($this->getWalkFlag() & self::WALK_X) {
            return $this->countX();
        } elseif ($this->getWalkFlag() & self::WALK_Y) {
            return $this->countY();
        } else {
            return $this->countXY();
        }
    }

public function count ( ) { if ( $ this -> getWalkFlag ( ) & self :: WALK_X ) { return $ this -> countX ( ) ; } elseif ( $ this -> getWalkFlag ( ) & self :: WALK_Y ) { return $ this -> countY ( ) ; } else { return $ this -> countXY ( ) ; } }

Count the number of values according to matrix's flag value

@return  int
@see     self::countX()
@see     self::countY()
@see     self::countXY()

Count the number of values according to matrix s flag value


public function seekToOffset($offset)
    {
        try {
            if (($this->getArrayFlag() & self::ARRAY_INT) && !is_string($offset)) {
                return $this->seekToOffsetInteger($offset);
            } else {
                return $this->seekToOffsetPositional($offset);
            }
        } catch (OutOfRangeException $e) {
            throw $e;
        }
    }

public function seekToOffset ( $ offset ) { try { if ( ( $ this -> getArrayFlag ( ) & self :: ARRAY_INT ) && ! is_string ( $ offset ) ) { return $ this -> seekToOffsetInteger ( $ offset ) ; } else { return $ this -> seekToOffsetPositional ( $ offset ) ; } } catch ( OutOfRangeException $ e ) { throw $ e ; } }

Seek `x` and `y` to an offset

@param   int/string   $offset
@return  $this
@throws  OutOfRangeException if the offset is out of range of matrix's indexes


public function seekToOffsetInteger($offset)
    {
        $indexes = explode(self::XY_SEPARATOR, $offset);
        try {
            if (count($indexes)==2) {
                if ($indexes[0]=='') {
                    $this->seekY($indexes[1]);
                } else {
                    $this->seekXY($offset);
                }
            } else {
                $this->seekX($offset);
            }
        } catch (OutOfRangeException $e) {
            throw $e;
        }
        return $this;
    }

public function seekToOffsetInteger ( $ offset ) { $ indexes = explode ( self :: XY_SEPARATOR , $ offset ) ; try { if ( count ( $ indexes ) == 2 ) { if ( $ indexes [ 0 ] == '' ) { $ this -> seekY ( $ indexes [ 1 ] ) ; } else { $ this -> seekXY ( $ offset ) ; } } else { $ this -> seekX ( $ offset ) ; } } catch ( OutOfRangeException $ e ) { throw $ e ; } return $ this ; }

Seek `x` and `y` to an integer offset

@param   int   $offset
@return  $this
@throws  OutOfRangeException if the offset is out of range of matrix's indexes


public function offsetExists($offset)
    {
        try {
            $res = $this
                ->seekToOffset($offset)
                ->valid();
        } catch (OutOfRangeException $e) {
            $res = false;
        }
        return (bool) $res;
    }

public function offsetExists ( $ offset ) { try { $ res = $ this -> seekToOffset ( $ offset ) -> valid ( ) ; } catch ( OutOfRangeException $ e ) { $ res = false ; } return ( bool ) $ res ; }

Test if an offset exists

@param   int/string   $offset
@return  bool


public function offsetGet($offset)
    {
        try {
            $res = $this
                ->seekToOffset($offset)
                ->current();
        } catch (OutOfRangeException $e) {
            $res = null;
            trigger_error("Undefined offset: '$offset'", E_USER_NOTICE);
        }
        return $res;
    }

public
function
offsetGet
(
$
offset
)
{
try
{
$
res
=
$
this
->
seekToOffset
(
$
offset
)
->
current
(
)
;
}
catch
(
OutOfRangeException
$
e
)
{
$
res
=
;
trigger_error
(
"Undefined offset: '$offset'"
,
E_USER_NOTICE
)
;
}
return
$
res
;
}

Get an offset value

@param   int/string   $offset
@return  mixed
@throws  Triggers a NOTICE message if the offset is out of range


public function offsetSet($offset, $value)
    {
        try {
            $this
                ->seekToOffset($offset)
                ->setInt($this->keyInt(), $value);
        } catch (OutOfRangeException $e) {
            trigger_error("Undefined offset: '$offset'", E_USER_NOTICE);
        }
        return $this;
    }

public
function
offsetSet
(
$
offset
,
$
value
)
{
try
{
$
this
->
seekToOffset
(
$
offset
)
->
setInt
(
$
this
->
keyInt
(
)
,
$
value
)
;
}
catch
(
OutOfRangeException
$
e
)
{
trigger_error
(
"Undefined offset: '$offset'"
,
E_USER_NOTICE
)
;
}
return
$
this
;
}

Set an offset value

@param   int/string   $offset
@param   mixed       $value
@return  $this
@throws  Triggers a NOTICE message if the offset is out of range


public function IsValid() {
        if (!is_bool($this->value)) {
            $errorMsg = 'The $value property of the instance of ' . __CLASS__ . ' is not a boolean.';
            throw new InvalidArgumentException($errorMsg, Codes\GeneralErrors::VALUE_IS_NOT_OF_EXPECTED_TYPE, null);
        }

        return true;
    }

Validates the property value.

@return boolean The result
@throws InvalidArgumentException


public function allowViewMethods(string $object, ...$allowedMethods)
    {
        if (isset($this->viewMethods[$object]) === false) {
            $this->viewMethods[$object] = [];
        }

        foreach ($allowedMethods as $allowedMethod) {
            $this->viewMethods[$object][$allowedMethod] = true;
        }
    }

public function allowViewMethods ( string $ object , ... $ allowedMethods ) { if ( isset ( $ this -> viewMethods [ $ object ] ) === false ) { $ this -> viewMethods [ $ object ] = [ ] ; } foreach ( $ allowedMethods as $ allowedMethod ) { $ this -> viewMethods [ $ object ] [ $ allowedMethod ] = true ; } }

Adds allowed view methods for an object

@return null


public function allowControllerMethods(string $object, ...$allowedMethods)
    {
        if (isset($this->controllerMethods[$object]) === false) {
            $this->controllerMethods[$object] = [];
        }

        foreach ($allowedMethods as $allowedMethod) {
            $this->controllerMethods[$object][$allowedMethod] = true;
        }
    }

public function allowControllerMethods ( string $ object , ... $ allowedMethods ) { if ( isset ( $ this -> controllerMethods [ $ object ] ) === false ) { $ this -> controllerMethods [ $ object ] = [ ] ; } foreach ( $ allowedMethods as $ allowedMethod ) { $ this -> controllerMethods [ $ object ] [ $ allowedMethod ] = true ; } }

Adds allowed controller methods for an object

@return null


public function table(string $table)
    {
        $this->changed = true;
        $this->table = $table;

        return $this;
    }

public function table ( string $ table ) { $ this -> changed = true ; $ this -> table = $ table ; return $ this ; }

Set the main table on which the query operates.

This is the table that follows UPDATE TABLE, INSERT INTO and
DELETE FROM.

@param  string $table
@return self

Set the main table on which the query operates .


public function from(string ...$table)
    {
        $this->changed = true;
        $this->from = $table;

        return $this;
    }

public function from ( string ... $ table ) { $ this -> changed = true ; $ this -> from = $ table ; return $ this ; }

Set the list of tables on which a SELECT query operates.

@param  string $table,...
@return self

Set the list of tables on which a SELECT query operates .


public function andWhere(array $conditions)
    {
        $this->changed = true;

        if ($this->conditions) {
            $this->conditions = [
                'AND',
                $this->conditions,
                $conditions,
            ];
        } else {
            $this->conditions = $conditions;
        }

        return $this;
    }

public function andWhere ( array $ conditions ) { $ this -> changed = true ; if ( $ this -> conditions ) { $ this -> conditions = [ 'AND' , $ this -> conditions , $ conditions , ] ; } else { $ this -> conditions = $ conditions ; } return $ this ; }

Add conditions for SELECT, UPDATE and DELETE queries with an AND operator.

@param  array  $conditions
@return self

Add conditions for SELECT UPDATE and DELETE queries with an AND operator .


public function orWhere(array $conditions)
    {
        $this->changed = true;

        if ($this->conditions) {
            $this->conditions = [
                'OR',
                $this->conditions,
                $conditions,
            ];
        } else {
            $this->conditions = $conditions;
        }

        return $this;
    }

public function orWhere ( array $ conditions ) { $ this -> changed = true ; if ( $ this -> conditions ) { $ this -> conditions = [ 'OR' , $ this -> conditions , $ conditions , ] ; } else { $ this -> conditions = $ conditions ; } return $ this ; }

Add conditions for SELECT, UPDATE and DELETE queries with an ON operator.

@param  array  $conditions
@return self

Add conditions for SELECT UPDATE and DELETE queries with an ON operator .


public function setStaticRule($name, $value)
    {
        $name = $this->_normalizeSpec($name);
        $this->_rules[$name] = (string) $value;
        return $this;
    }

public function setStaticRule ( $ name , $ value ) { $ name = $ this -> _normalizeSpec ( $ name ) ; $ this -> _rules [ $ name ] = ( string ) $ value ; return $ this ; }

Set a static rule for a spec.  This is a single string value

@param string $name
@param string $value
@return Zend_Filter_Inflector

Set a static rule for a spec . This is a single string value


public function setStaticRuleReference($name, &$reference)
    {
        $name = $this->_normalizeSpec($name);
        $this->_rules[$name] =& $reference;
        return $this;
    }

public function setStaticRuleReference ( $ name , & $ reference ) { $ name = $ this -> _normalizeSpec ( $ name ) ; $ this -> _rules [ $ name ] = & $ reference ; return $ this ; }

Set Static Rule Reference.

This allows a consuming class to pass a property or variable
in to be referenced when its time to build the output string from the
target.

@param string $name
@param mixed $reference
@return Zend_Filter_Inflector


protected function _getRule($rule)
    {
        if ($rule instanceof Zend_Filter_Interface) {
            return $rule;
        }

        $rule = (string) $rule;

        $className  = $this->getPluginLoader()->load($rule);
        $ruleObject = new $className();
        if (!$ruleObject instanceof Zend_Filter_Interface) {

            throw new Zend_Filter_Exception('No class named ' . $rule . ' implementing Zend_Filter_Interface could be found');
        }

        return $ruleObject;
    }

Resolve named filters and convert them to filter objects.

@param  string $rule
@return Zend_Filter_Interface

Resolve named filters and convert them to filter objects .


public function endBody()
    {
        $this->emit(self::EVENT_END_BODY, [$this]);
        echo self::PH_BODY_END;

        foreach (array_keys($this->assetBundles) as $bundle) {
            $this->registerAssetFiles($bundle);
        }
    }

public function endBody ( ) { $ this -> emit ( self :: EVENT_END_BODY , [ $ this ] ) ; echo self :: PH_BODY_END ; foreach ( array_keys ( $ this -> assetBundles ) as $ bundle ) { $ this -> registerAssetFiles ( $ bundle ) ; } }

Marks the ending of an HTML body section.

Marks the ending of an HTML body section .


public function registerJsFile($url, $options = [], $key = null)
    {
        $url = \Reaction::$app->getAlias($url);
        $key = $key ?: $url;
        $helpers = $this->app->helpers;

        $depends = ArrayHelper::remove($options, 'depends', []);

        if (empty($depends)) {
            $position = ArrayHelper::remove($options, 'position', self::POS_END);
            $this->jsFiles[$position][$key] = $helpers->html->jsFile($url, $options);
        } else {
            $this->getAssetManager()->bundles[$key] = Reaction::create([
                'class' => AssetBundle::class,
                'baseUrl' => '',
                'js' => [strncmp($url, '//', 2) === 0 ? $url : ltrim($url, '/')],
                'jsOptions' => $options,
                'depends' => (array)$depends,
            ]);
            $this->registerAssetBundle($key);
        }
    }

public function registerJsFile ( $ url , $ options = [ ] , $ key = null ) { $ url = \ Reaction :: $ app -> getAlias ( $ url ) ; $ key = $ key ? : $ url ; $ helpers = $ this -> app -> helpers ; $ depends = ArrayHelper :: remove ( $ options , 'depends' , [ ] ) ; if ( empty ( $ depends ) ) { $ position = ArrayHelper :: remove ( $ options , 'position' , self :: POS_END ) ; $ this -> jsFiles [ $ position ] [ $ key ] = $ helpers -> html -> jsFile ( $ url , $ options ) ; } else { $ this -> getAssetManager ( ) -> bundles [ $ key ] = Reaction :: create ( [ 'class' => AssetBundle :: class , 'baseUrl' => '' , 'js' => [ strncmp ( $ url , '//' , 2 ) === 0 ? $ url : ltrim ( $ url , '/' ) ] , 'jsOptions' => $ options , 'depends' => ( array ) $ depends , ] ) ; $ this -> registerAssetBundle ( $ key ) ; } }

Registers a JS file.

This method should be used for simple registration of JS files. If you want to use features of
[[AssetManager]] like appending timestamps to the URL and file publishing options, use [[AssetBundle]]
and [[registerAssetBundle()]] instead.

@param string $url the JS file to be registered.
@param array $options the HTML attributes for the script tag. The following options are specially handled
and are not treated as HTML attributes:

- `depends`: array, specifies the names of the asset bundles that this JS file depends on.
- `position`: specifies where the JS script tag should be inserted in a page. The possible values are:
* [[POS_HEAD]]: in the head section
* [[POS_BEGIN]]: at the beginning of the body section
* [[POS_END]]: at the end of the body section. This is the default value.

Please refer to [[Html::jsFile()]] for other supported options.

@param string $key the key that identifies the JS script file. If null, it will use
$url as the key. If two JS files are registered with the same key at the same position, the latter
will overwrite the former. Note that position option takes precedence, thus files registered with the same key,
but different position option will not override each other.


public function registerJsVar($name, $value, $position = self::POS_HEAD)
    {
        $js = sprintf('var %s = %s;', $name, Json::htmlEncode($value));
        $this->registerJs($js, $position, $name);
    }

public
function
registerJsVar
(
$
name
,
$
value
,
$
position
=
self
::
POS_HEAD
)
{
$
js
=
sprintf
(
'var %s = %s;'
,
$
name
,
Json
::
htmlEncode
(
$
value
)
)
;
$
this
->
registerJs
(
$
js
,
$
position
,
$
name
)
;
}

Registers a JS code block defining a variable. The name of variable will be
used as key, preventing duplicated variable names.

@param string $name Name of the variable
@param array|string $value Value of the variable
@param int $position the position in a page at which the JavaScript variable should be inserted.
The possible values are:

- [[POS_HEAD]]: in the head section. This is the default value.
- [[POS_BEGIN]]: at the beginning of the body section.
- [[POS_END]]: at the end of the body section.
- [[POS_LOAD]]: enclosed within jQuery(window).load().
Note that by using this position, the method will automatically register the jQuery js file.
- [[POS_READY]]: enclosed within jQuery(document).ready().
Note that by using this position, the method will automatically register the jQuery js file.

Registers a JS code block defining a variable . The name of variable will be used as key preventing duplicated variable names .


function getDefaultConfigFiles()
    {
        $sl = DIRECTORY_SEPARATOR;
        if (OS_WINDOWS) {
            return array(
                'user'   => PEAR_CONFIG_SYSCONFDIR . $sl . 'pear.ini',
                'system' =>  PEAR_CONFIG_SYSCONFDIR . $sl . 'pearsys.ini'
            );
        }

        return array(
            'user'   => getenv('HOME') . $sl . '.pearrc',
            'system' => PEAR_CONFIG_SYSCONFDIR . $sl . 'pear.conf'
        );
    }

function getDefaultConfigFiles ( ) { $ sl = DIRECTORY_SEPARATOR ; if ( OS_WINDOWS ) { return array ( 'user' => PEAR_CONFIG_SYSCONFDIR . $ sl . 'pear.ini' , 'system' => PEAR_CONFIG_SYSCONFDIR . $ sl . 'pearsys.ini' ) ; } return array ( 'user' => getenv ( 'HOME' ) . $ sl . '.pearrc' , 'system' => PEAR_CONFIG_SYSCONFDIR . $ sl . 'pear.conf' ) ; }

Return the default locations of user and system configuration files
@static


function &singleton($user_file = '', $system_file = '', $strict = true)
    {
        if (is_object($GLOBALS['_PEAR_Config_instance'])) {
            return $GLOBALS['_PEAR_Config_instance'];
        }

        $t_conf = &new PEAR_Config($user_file, $system_file, false, $strict);
        if ($t_conf->_errorsFound > 0) {
             return $t_conf->lastError;
        }

        $GLOBALS['_PEAR_Config_instance'] = &$t_conf;
        return $GLOBALS['_PEAR_Config_instance'];
    }

function & singleton ( $ user_file = '' , $ system_file = '' , $ strict = true ) { if ( is_object ( $ GLOBALS [ '_PEAR_Config_instance' ] ) ) { return $ GLOBALS [ '_PEAR_Config_instance' ] ; } $ t_conf = & new PEAR_Config ( $ user_file , $ system_file , false , $ strict ) ; if ( $ t_conf -> _errorsFound > 0 ) { return $ t_conf -> lastError ; } $ GLOBALS [ '_PEAR_Config_instance' ] = & $ t_conf ; return $ GLOBALS [ '_PEAR_Config_instance' ] ; }

Static singleton method.  If you want to keep only one instance
of this class in use, this method will give you a reference to
the last created PEAR_Config object if one exists, or create a
new object.

@param string (optional) file to read user-defined options from
@param string (optional) file to read system-wide defaults from

@return object an existing or new PEAR_Config instance

@access public

@see PEAR_Config::PEAR_Config

Static singleton method . If you want to keep only one instance of this class in use this method will give you a reference to the last created PEAR_Config object if one exists or create a new object .


function _setupChannels()
    {
        $set = array_flip(array_values($this->_channels));
        foreach ($this->configuration as $layer => $data) {
            $i = 1000;
            if (isset($data['__channels']) && is_array($data['__channels'])) {
                foreach ($data['__channels'] as $channel => $info) {
                    $set[$channel] = $i++;
                }
            }
        }
        $this->_channels = array_values(array_flip($set));
        $this->setChannels($this->_channels);
    }

function _setupChannels ( ) { $ set = array_flip ( array_values ( $ this -> _channels ) ) ; foreach ( $ this -> configuration as $ layer => $ data ) { $ i = 1000 ; if ( isset ( $ data [ '__channels' ] ) && is_array ( $ data [ '__channels' ] ) ) { foreach ( $ data [ '__channels' ] as $ channel => $ info ) { $ set [ $ channel ] = $ i ++ ; } } } $ this -> _channels = array_values ( array_flip ( $ set ) ) ; $ this -> setChannels ( $ this -> _channels ) ; }

Reads the existing configurations and creates the _channels array from it


function mergeConfigFile($file, $override = true, $layer = 'user', $strict = true)
    {
        if (empty($this->files[$layer])) {
            return $this->raiseError("unknown config layer `$layer'");
        }

        if ($file === null) {
            $file = $this->files[$layer];
        }

        $data = $this->_readConfigDataFrom($file);
        if (PEAR::isError($data)) {
            if (!$strict) {
                return true;
            }

            $this->_errorsFound++;
            $this->lastError = $data;

            return $data;
        }

        $this->_decodeInput($data);
        if ($override) {
            $this->configuration[$layer] =
                PEAR_Config::arrayMergeRecursive($this->configuration[$layer], $data);
        } else {
            $this->configuration[$layer] =
                PEAR_Config::arrayMergeRecursive($data, $this->configuration[$layer]);
        }

        $this->_setupChannels();
        if (!$this->_noRegistry && ($phpdir = $this->get('php_dir', $layer, 'pear.php.net'))) {
            $this->_registry[$layer] = &new PEAR_Registry($phpdir);
            $this->_registry[$layer]->setConfig($this, false);
            $this->_regInitialized[$layer] = false;
        } else {
            unset($this->_registry[$layer]);
        }
        return true;
    }

function
mergeConfigFile
(
$
file
,
$
override
=
true
,
$
layer
=
'user'
,
$
strict
=
true
)
{
if
(
empty
(
$
this
->
files
[
$
layer
]
)
)
{
return
$
this
->
raiseError
(
"unknown config layer `$layer'"
)
;
}
if
(
$
file
===
)
{
$
file
=
$
this
->
files
[
$
layer
]
;
}
$
data
=
$
this
->
_readConfigDataFrom
(
$
file
)
;
if
(
PEAR
::
isError
(
$
data
)
)
{
if
(
!
$
strict
)
{
return
true
;
}
$
this
->
_errorsFound
++
;
$
this
->
lastError
=
$
data
;
return
$
data
;
}
$
this
->
_decodeInput
(
$
data
)
;
if
(
$
override
)
{
$
this
->
configuration
[
$
layer
]
=
PEAR_Config
::
arrayMergeRecursive
(
$
this
->
configuration
[
$
layer
]
,
$
data
)
;
}
else
{
$
this
->
configuration
[
$
layer
]
=
PEAR_Config
::
arrayMergeRecursive
(
$
data
,
$
this
->
configuration
[
$
layer
]
)
;
}
$
this
->
_setupChannels
(
)
;
if
(
!
$
this
->
_noRegistry
&&
(
$
phpdir
=
$
this
->
get
(
'php_dir'
,
$
layer
,
'pear.php.net'
)
)
)
{
$
this
->
_registry
[
$
layer
]
=
&
new
PEAR_Registry
(
$
phpdir
)
;
$
this
->
_registry
[
$
layer
]
->
setConfig
(
$
this
,
false
)
;
$
this
->
_regInitialized
[
$
layer
]
=
false
;
}
else
{
unset
(
$
this
->
_registry
[
$
layer
]
)
;
}
return
true
;
}

Merges data into a config layer from a file.  Does the same
thing as readConfigFile, except it does not replace all
existing values in the config layer.
@param string file to read from
@param bool whether to overwrite existing data (default TRUE)
@param string config layer to insert data into ('user' or 'system')
@param string if true, errors are returned if file opening fails
@return bool TRUE on success or a PEAR error on failure

Merges data into a config layer from a file . Does the same thing as readConfigFile except it does not replace all existing values in the config layer .


function writeConfigFile($file = null, $layer = 'user', $data = null)
    {
        $this->_lazyChannelSetup($layer);
        if ($layer == 'both' || $layer == 'all') {
            foreach ($this->files as $type => $file) {
                $err = $this->writeConfigFile($file, $type, $data);
                if (PEAR::isError($err)) {
                    return $err;
                }
            }
            return true;
        }

        if (empty($this->files[$layer])) {
            return $this->raiseError("unknown config file type `$layer'");
        }

        if ($file === null) {
            $file = $this->files[$layer];
        }

        $data = ($data === null) ? $this->configuration[$layer] : $data;
        $this->_encodeOutput($data);
        $opt = array('-p', dirname($file));
        if (!@System::mkDir($opt)) {
            return $this->raiseError("could not create directory: " . dirname($file));
        }

        if (file_exists($file) && is_file($file) && !is_writeable($file)) {
            return $this->raiseError("no write access to $file!");
        }

        $fp = @fopen($file, "w");
        if (!$fp) {
            return $this->raiseError("PEAR_Config::writeConfigFile fopen('$file','w') failed ($php_errormsg)");
        }

        $contents = "#PEAR_Config 0.9\n" . serialize($data);
        if (!@fwrite($fp, $contents)) {
            return $this->raiseError("PEAR_Config::writeConfigFile: fwrite failed ($php_errormsg)");
        }
        return true;
    }

Writes data into a config layer from a file.

@param string|null file to read from, or null for default
@param string config layer to insert data into ('user' or
'system')
@param string|null data to write to config file or null for internal data [DEPRECATED]
@return bool TRUE on success or a PEAR error on failure

Writes data into a config layer from a file .


function _readConfigDataFrom($file)
    {
        $fp = false;
        if (file_exists($file)) {
            $fp = @fopen($file, "r");
        }

        if (!$fp) {
            return $this->raiseError("PEAR_Config::readConfigFile fopen('$file','r') failed");
        }

        $size = filesize($file);
        $rt = get_magic_quotes_runtime();
        set_magic_quotes_runtime(0);
        fclose($fp);
        $contents = file_get_contents($file);
        if (empty($contents)) {
            return $this->raiseError('Configuration file "' . $file . '" is empty');
        }

        set_magic_quotes_runtime($rt);

        $version = false;
        if (preg_match('/^#PEAR_Config\s+(\S+)\s+/si', $contents, $matches)) {
            $version = $matches[1];
            $contents = substr($contents, strlen($matches[0]));
        } else {
            // Museum config file
            if (substr($contents,0,2) == 'a:') {
                $version = '0.1';
            }
        }

        if ($version && version_compare("$version", '1', '<')) {
            // no '@', it is possible that unserialize
            // raises a notice but it seems to block IO to
            // STDOUT if a '@' is used and a notice is raise
            $data = unserialize($contents);

            if (!is_array($data) && !$data) {
                if ($contents == serialize(false)) {
                    $data = array();
                } else {
                    $err = $this->raiseError("PEAR_Config: bad data in $file");
                    return $err;
                }
            }
            if (!is_array($data)) {
                if (strlen(trim($contents)) > 0) {
                    $error = "PEAR_Config: bad data in $file";
                    $err = $this->raiseError($error);
                    return $err;
                }

                $data = array();
            }
        // add parsing of newer formats here...
        } else {
            $err = $this->raiseError("$file: unknown version `$version'");
            return $err;
        }

        return $data;
    }

Reads configuration data from a file and returns the parsed data
in an array.

@param string file to read from
@return array configuration data or a PEAR error on failure
@access private

Reads configuration data from a file and returns the parsed data in an array .


function getDefaultChannel($layer = null)
    {
        $ret = false;
        if ($layer === null) {
            foreach ($this->layers as $layer) {
                if (isset($this->configuration[$layer]['default_channel'])) {
                    $ret = $this->configuration[$layer]['default_channel'];
                    break;
                }
            }
        } elseif (isset($this->configuration[$layer]['default_channel'])) {
            $ret = $this->configuration[$layer]['default_channel'];
        }

        if ($ret == 'pear.php.net' && defined('PEAR_RUNTYPE') && PEAR_RUNTYPE == 'pecl') {
            $ret = 'pecl.php.net';
        }

        if ($ret) {
            if ($ret != 'pear.php.net') {
                $this->_lazyChannelSetup();
            }

            return $ret;
        }

        return PEAR_CONFIG_DEFAULT_CHANNEL;
    }

function getDefaultChannel ( $ layer = null ) { $ ret = false ; if ( $ layer === null ) { foreach ( $ this -> layers as $ layer ) { if ( isset ( $ this -> configuration [ $ layer ] [ 'default_channel' ] ) ) { $ ret = $ this -> configuration [ $ layer ] [ 'default_channel' ] ; break ; } } } elseif ( isset ( $ this -> configuration [ $ layer ] [ 'default_channel' ] ) ) { $ ret = $ this -> configuration [ $ layer ] [ 'default_channel' ] ; } if ( $ ret == 'pear.php.net' && defined ( 'PEAR_RUNTYPE' ) && PEAR_RUNTYPE == 'pecl' ) { $ ret = 'pecl.php.net' ; } if ( $ ret ) { if ( $ ret != 'pear.php.net' ) { $ this -> _lazyChannelSetup ( ) ; } return $ ret ; } return PEAR_CONFIG_DEFAULT_CHANNEL ; }

Retrieve the default channel.

On startup, channels are not initialized, so if the default channel is not
pear.php.net, then initialize the config.
@param string registry layer
@return string|false


function _getChannelValue($key, $layer, $channel)
    {
        if ($key == '__channels' || $channel == 'pear.php.net') {
            return null;
        }

        $ret = null;
        if ($layer === null) {
            foreach ($this->layers as $ilayer) {
                if (isset($this->configuration[$ilayer]['__channels'][$channel][$key])) {
                    $ret = $this->configuration[$ilayer]['__channels'][$channel][$key];
                    break;
                }
            }
        } elseif (isset($this->configuration[$layer]['__channels'][$channel][$key])) {
            $ret = $this->configuration[$layer]['__channels'][$channel][$key];
        }

        if ($key != 'preferred_mirror') {
            return $ret;
        }

        if ($ret !== null) {
            $reg = &$this->getRegistry($layer);
            if (is_object($reg)) {
                $chan = &$reg->getChannel($channel);
                if (PEAR::isError($chan)) {
                    return $channel;
                }

                if (!$chan->getMirror($ret) && $chan->getName() != $ret) {
                    return $channel; // mirror does not exist
                }
            }

            return $ret;
        }

        if ($channel != $this->getDefaultChannel($layer)) {
            return $channel; // we must use the channel name as the preferred mirror
                             // if the user has not chosen an alternate
        }

        return $this->getDefaultChannel($layer);
    }

Returns a channel-specific configuration value, prioritizing layers as per the
layers property.

@param string config key
@return mixed the config value, or NULL if not found
@access private

Returns a channel - specific configuration value prioritizing layers as per the layers property .


function setChannels($channels, $merge = false)
    {
        if (!is_array($channels)) {
            return false;
        }

        if ($merge) {
            $this->_channels = array_merge($this->_channels, $channels);
        } else {
            $this->_channels = $channels;
        }

        foreach ($channels as $channel) {
            $channel = strtolower($channel);
            if ($channel == 'pear.php.net') {
                continue;
            }

            foreach ($this->layers as $layer) {
                if (!isset($this->configuration[$layer]['__channels'])) {
                    $this->configuration[$layer]['__channels'] = array();
                }
                if (!isset($this->configuration[$layer]['__channels'][$channel])
                      || !is_array($this->configuration[$layer]['__channels'][$channel])) {
                    $this->configuration[$layer]['__channels'][$channel] = array();
                }
            }
        }

        return true;
    }

function setChannels ( $ channels , $ merge = false ) { if ( ! is_array ( $ channels ) ) { return false ; } if ( $ merge ) { $ this -> _channels = array_merge ( $ this -> _channels , $ channels ) ; } else { $ this -> _channels = $ channels ; } foreach ( $ channels as $ channel ) { $ channel = strtolower ( $ channel ) ; if ( $ channel == 'pear.php.net' ) { continue ; } foreach ( $ this -> layers as $ layer ) { if ( ! isset ( $ this -> configuration [ $ layer ] [ '__channels' ] ) ) { $ this -> configuration [ $ layer ] [ '__channels' ] = array ( ) ; } if ( ! isset ( $ this -> configuration [ $ layer ] [ '__channels' ] [ $ channel ] ) || ! is_array ( $ this -> configuration [ $ layer ] [ '__channels' ] [ $ channel ] ) ) { $ this -> configuration [ $ layer ] [ '__channels' ] [ $ channel ] = array ( ) ; } } } return true ; }

Set the list of channels.

This should be set via a call to {@link PEAR_Registry::listChannels()}
@param array
@param bool
@return bool success of operation


function getType($key)
    {
        if (isset($this->configuration_info[$key])) {
            return $this->configuration_info[$key]['type'];
        }
        return false;
    }

function getType ( $ key ) { if ( isset ( $ this -> configuration_info [ $ key ] ) ) { return $ this -> configuration_info [ $ key ] [ 'type' ] ; } return false ; }

Get the type of a config value.

@param string  config key

@return string type, one of "string", "integer", "file",
"directory", "set" or "password".

@access public


function getDocs($key)
    {
        if (isset($this->configuration_info[$key])) {
            return $this->configuration_info[$key]['doc'];
        }

        return false;
    }

function getDocs ( $ key ) { if ( isset ( $ this -> configuration_info [ $ key ] ) ) { return $ this -> configuration_info [ $ key ] [ 'doc' ] ; } return false ; }

Get the documentation for a config value.

@param string  config key
@return string documentation string

@access public

Get the documentation for a config value .


function getPrompt($key)
    {
        if (isset($this->configuration_info[$key])) {
            return $this->configuration_info[$key]['prompt'];
        }

        return false;
    }

function getPrompt ( $ key ) { if ( isset ( $ this -> configuration_info [ $ key ] ) ) { return $ this -> configuration_info [ $ key ] [ 'prompt' ] ; } return false ; }

Get the short documentation for a config value.

@param string  config key
@return string short documentation string

@access public

Get the short documentation for a config value .


function getGroup($key)
    {
        if (isset($this->configuration_info[$key])) {
            return $this->configuration_info[$key]['group'];
        }

        return false;
    }

function getGroup ( $ key ) { if ( isset ( $ this -> configuration_info [ $ key ] ) ) { return $ this -> configuration_info [ $ key ] [ 'group' ] ; } return false ; }

Get the parameter group for a config key.

@param string  config key
@return string parameter group

@access public

Get the parameter group for a config key .


function getGroups()
    {
        $tmp = array();
        foreach ($this->configuration_info as $key => $info) {
            $tmp[$info['group']] = 1;
        }

        return array_keys($tmp);
    }

function getGroups ( ) { $ tmp = array ( ) ; foreach ( $ this -> configuration_info as $ key => $ info ) { $ tmp [ $ info [ 'group' ] ] = 1 ; } return array_keys ( $ tmp ) ; }

Get the list of parameter groups.

@return array list of parameter groups

@access public


function getGroupKeys($group)
    {
        $keys = array();
        foreach ($this->configuration_info as $key => $info) {
            if ($info['group'] == $group) {
                $keys[] = $key;
            }
        }

        return $keys;
    }

function getGroupKeys ( $ group ) { $ keys = array ( ) ; foreach ( $ this -> configuration_info as $ key => $ info ) { if ( $ info [ 'group' ] == $ group ) { $ keys [ ] = $ key ; } } return $ keys ; }

Get the list of the parameters in a group.

@param string $group parameter group
@return array list of parameters in $group

@access public

Get the list of the parameters in a group .


function getSetValues($key)
    {
        if (isset($this->configuration_info[$key]) &&
            isset($this->configuration_info[$key]['type']) &&
            $this->configuration_info[$key]['type'] == 'set')
        {
            $valid_set = $this->configuration_info[$key]['valid_set'];
            reset($valid_set);
            if (key($valid_set) === 0) {
                return $valid_set;
            }

            return array_keys($valid_set);
        }

        return null;
    }

function getSetValues ( $ key ) { if ( isset ( $ this -> configuration_info [ $ key ] ) && isset ( $ this -> configuration_info [ $ key ] [ 'type' ] ) && $ this -> configuration_info [ $ key ] [ 'type' ] == 'set' ) { $ valid_set = $ this -> configuration_info [ $ key ] [ 'valid_set' ] ; reset ( $ valid_set ) ; if ( key ( $ valid_set ) === 0 ) { return $ valid_set ; } return array_keys ( $ valid_set ) ; } return null ; }

Get the list of allowed set values for a config value.  Returns
NULL for config values that are not sets.

@param string  config key
@return array enumerated array of set values, or NULL if the
config key is unknown or not a set

@access public

Get the list of allowed set values for a config value . Returns NULL for config values that are not sets .


function getKeys()
    {
        $keys = array();
        foreach ($this->layers as $layer) {
            $test = $this->configuration[$layer];
            if (isset($test['__channels'])) {
                foreach ($test['__channels'] as $channel => $configs) {
                    $keys = array_merge($keys, $configs);
                }
            }

            unset($test['__channels']);
            $keys = array_merge($keys, $test);

        }
        return array_keys($keys);
    }

function getKeys ( ) { $ keys = array ( ) ; foreach ( $ this -> layers as $ layer ) { $ test = $ this -> configuration [ $ layer ] ; if ( isset ( $ test [ '__channels' ] ) ) { foreach ( $ test [ '__channels' ] as $ channel => $ configs ) { $ keys = array_merge ( $ keys , $ configs ) ; } } unset ( $ test [ '__channels' ] ) ; $ keys = array_merge ( $ keys , $ test ) ; } return array_keys ( $ keys ) ; }

Get all the current config keys.

@return array simple array of config keys

@access public


function remove($key, $layer = 'user', $channel = null)
    {
        if ($channel === null) {
            $channel = $this->getDefaultChannel();
        }

        if ($channel !== 'pear.php.net') {
            if (isset($this->configuration[$layer]['__channels'][$channel][$key])) {
                unset($this->configuration[$layer]['__channels'][$channel][$key]);
                return true;
            }
        }

        if (isset($this->configuration[$layer][$key])) {
            unset($this->configuration[$layer][$key]);
            return true;
        }

        return false;
    }

function remove ( $ key , $ layer = 'user' , $ channel = null ) { if ( $ channel === null ) { $ channel = $ this -> getDefaultChannel ( ) ; } if ( $ channel !== 'pear.php.net' ) { if ( isset ( $ this -> configuration [ $ layer ] [ '__channels' ] [ $ channel ] [ $ key ] ) ) { unset ( $ this -> configuration [ $ layer ] [ '__channels' ] [ $ channel ] [ $ key ] ) ; return true ; } } if ( isset ( $ this -> configuration [ $ layer ] [ $ key ] ) ) { unset ( $ this -> configuration [ $ layer ] [ $ key ] ) ; return true ; } return false ; }

Remove the a config key from a specific config layer.

@param string config key
@param string (optional) config layer
@param string (optional) channel (defaults to default channel)
@return bool TRUE on success, FALSE on failure

@access public

Remove the a config key from a specific config layer .


function removeLayer($layer)
    {
        if (isset($this->configuration[$layer])) {
            $this->configuration[$layer] = array();
            return true;
        }

        return false;
    }

function removeLayer ( $ layer ) { if ( isset ( $ this -> configuration [ $ layer ] ) ) { $ this -> configuration [ $ layer ] = array ( ) ; return true ; } return false ; }

Temporarily remove an entire config layer.  USE WITH CARE!

@param string config key
@param string (optional) config layer
@return bool TRUE on success, FALSE on failure

@access public

Temporarily remove an entire config layer . USE WITH CARE!


function definedBy($key, $returnchannel = false)
    {
        foreach ($this->layers as $layer) {
            $channel = $this->getDefaultChannel();
            if ($channel !== 'pear.php.net') {
                if (isset($this->configuration[$layer]['__channels'][$channel][$key])) {
                    if ($returnchannel) {
                        return array('layer' => $layer, 'channel' => $channel);
                    }
                    return $layer;
                }
            }

            if (isset($this->configuration[$layer][$key])) {
                if ($returnchannel) {
                    return array('layer' => $layer, 'channel' => 'pear.php.net');
                }
                return $layer;
            }
        }

        return '';
    }

function definedBy ( $ key , $ returnchannel = false ) { foreach ( $ this -> layers as $ layer ) { $ channel = $ this -> getDefaultChannel ( ) ; if ( $ channel !== 'pear.php.net' ) { if ( isset ( $ this -> configuration [ $ layer ] [ '__channels' ] [ $ channel ] [ $ key ] ) ) { if ( $ returnchannel ) { return array ( 'layer' => $ layer , 'channel' => $ channel ) ; } return $ layer ; } } if ( isset ( $ this -> configuration [ $ layer ] [ $ key ] ) ) { if ( $ returnchannel ) { return array ( 'layer' => $ layer , 'channel' => 'pear.php.net' ) ; } return $ layer ; } } return '' ; }

Tells what config layer that gets to define a key.

@param string config key
@param boolean return the defining channel

@return string|array the config layer, or an empty string if not found.

if $returnchannel, the return is an array array('layer' => layername,
'channel' => channelname), or an empty string if not found

@access public

Tells what config layer that gets to define a key .


function isDefined($key)
    {
        foreach ($this->layers as $layer) {
            if (isset($this->configuration[$layer][$key])) {
                return true;
            }
        }

        return false;
    }

function isDefined ( $ key ) { foreach ( $ this -> layers as $ layer ) { if ( isset ( $ this -> configuration [ $ layer ] [ $ key ] ) ) { return true ; } } return false ; }

Tells whether a given key exists as a config value.

@param string config key
@return bool whether <config key> exists in this object

@access public

Tells whether a given key exists as a config value .


function setRegistry(&$reg, $layer = 'user')
    {
        if ($this->_noRegistry) {
            return false;
        }

        if (!in_array($layer, array('user', 'system'))) {
            return false;
        }

        $this->_registry[$layer] = &$reg;
        if (is_object($reg)) {
            $this->_registry[$layer]->setConfig($this, false);
        }

        return true;
    }

function setRegistry ( & $ reg , $ layer = 'user' ) { if ( $ this -> _noRegistry ) { return false ; } if ( ! in_array ( $ layer , array ( 'user' , 'system' ) ) ) { return false ; } $ this -> _registry [ $ layer ] = & $ reg ; if ( is_object ( $ reg ) ) { $ this -> _registry [ $ layer ] -> setConfig ( $ this , false ) ; } return true ; }

This is to allow customization like the use of installroot
@param PEAR_Registry
@return bool


protected function _processExtends(array $data, $section, array $config = array())
    {
        if (!isset($data[$section])) {

            throw new Zend_Config_Exception(sprintf('Section "%s" cannot be found', $section));
        }

        $thisSection  = $data[$section];

        if (is_array($thisSection) && isset($thisSection[self::EXTENDS_NAME])) {
            if (is_array($thisSection[self::EXTENDS_NAME])) {

                throw new Zend_Config_Exception('Invalid extends clause: must be a string; array received');
            }
            $this->_assertValidExtend($section, $thisSection[self::EXTENDS_NAME]);

            if (!$this->_skipExtends) {
                $config = $this->_processExtends($data, $thisSection[self::EXTENDS_NAME], $config);
            }
            unset($thisSection[self::EXTENDS_NAME]);
        }

        $config = $this->_arrayMergeRecursive($config, $thisSection);

        return $config;
    }

Helper function to process each element in the section and handle
the "_extends" inheritance attribute.

@param  array            $data Data array to process
@param  string           $section Section to process
@param  array            $config  Configuration which was parsed yet
@throws Zend_Config_Exception When $section cannot be found
@return array

Helper function to process each element in the section and handle the _extends inheritance attribute .


protected function _replaceConstants($value)
    {
        foreach ($this->_getConstants() as $constant) {
            if (strstr($value, $constant)) {
                // handle backslashes that may represent windows path names for instance
                $replacement = str_replace('\\', '\\\\', constant($constant));
                $value = str_replace($constant, $replacement, $value);
            }
        }
        return $value;
    }

Replace any constants referenced in a string with their values

@param  string $value
@return string


protected function getCallback(): callable
    {
        if ($this->callback === null) {
            $this->callback = function (LogInterface $log): array {
                $metaData = $log->getMetaData() ?: null;
                if (is_array($metaData) === true) {
                    $metaData = json_encode($metaData, JSON_PARTIAL_OUTPUT_ON_ERROR | JSON_UNESCAPED_SLASHES);
                }

                $priority = $log->getPriority();

                return [
                    'value' => $priority->getValue(),
                    'keyword' => strtoupper($priority->getKeyword()),
                    'date_time' => $log->getDateTime()->format('Y-m-d H:i:s'),
                    'message' => $log->getMessage(),
                    'meta_data' => $metaData,
                ];
            };
        }

        return $this->callback;
    }

protected
function
getCallback
(
)
:
callable
{
if
(
$
this
->
callback
===
)
{
$
this
->
callback
=
function
(
LogInterface
$
log
)
:
array
{
$
metaData
=
$
log
->
getMetaData
(
)
:
;
if
(
is_array
(
$
metaData
)
===
true
)
{
$
metaData
=
json_encode
(
$
metaData
,
JSON_PARTIAL_OUTPUT_ON_ERROR
|
JSON_UNESCAPED_SLASHES
)
;
}
$
priority
=
$
log
->
getPriority
(
)
;
return
[
'value'
=>
$
priority
->
getValue
(
)
,
'keyword'
=>
strtoupper
(
$
priority
->
getKeyword
(
)
)
,
'date_time'
=>
$
log
->
getDateTime
(
)
->
format
(
'Y-m-d H:i:s'
)
,
'message'
=>
$
log
->
getMessage
(
)
,
'meta_data'
=>
$
metaData
,
]
;
}
;
}
return
$
this
->
callback
;
}

Get parameter callback.

@return callable


public static function isValid($value): bool
    {
        if (\is_array($value) || \is_object($value)) {
            return false;
        }

        // Get the valid values to compare with
        $validValues = static::validValues();

        // If the value isset in the valid values array and the value matches
        // the value to check
        // ?? Why is this here ??
        // As is known by all isset is faster than in_array. We want to
        // capitalize on that with some enums by making the const VALUES
        // array a key value pair of the value itself so that we've
        // essentially got value => value for each item in the const VALUES
        // array. This way we can take advantage of the quickness of isset over
        // in_array. However, because not all enums may do this we need to
        // ensure if the value isset as the key in the array that it also
        // matches as the value of that item in the array, otherwise we'll
        // get false positives where its a normal array of 0 => value, 1 =>
        // value and we check for 0 being a valid value where it may very
        // well not be valid at all.
        if (isset($validValues[$value]) && $validValues[$value] === $value) {
            return true;
        }

        return \in_array($value, $validValues, true);
    }

Check if the set value on this enum is a valid value for the enum.

@param mixed $value The value to check

@return bool

Check if the set value on this enum is a valid value for the enum .


public static function validValues(): array
    {
        // If the const VALUES array has been populated
        if (null !== static::VALUES) {
            // Use it as the developer took the time to define it
            return static::VALUES;
        }

        // Get the class name that was called
        $className = static::class;

        // If the called enum isn't yet cached
        // and the values aren't already set (to avoid a reflection class)
        if (! array_key_exists($className, self::$cache)) {
            // Set the cache to avoid a reflection class creation on each new
            // instance of the enum
            self::$cache[$className] = static::reflectionValidValues();
        }

        return self::$cache[$className] ?? [];
    }

Get the valid values for this enum.

@return array


protected static function reflectionValidValues(): array
    {
        try {
            // Get a reflection class of the enum
            $reflectionClass = new ReflectionClass(static::class);
            $values          = $reflectionClass->getConstants();
        } // Catch any exceptions
        catch (\Exception $exception) {
            $values = [];
        }

        $validValues = [];

        // Iterate through the values
        foreach ($values as $key => $value) {
            // If this value is defined in this abstract Enum (self)
            if (\defined(self::class . '::' . $key)) {
                // Unset it from the list as its not a valid Enum value, but
                // rather a value the Enum class needs (like self::VALUES)
                unset($values[$key]);

                continue;
            }

            $validValues[$value] = $value;
        }

        return $validValues;
    }

Get the reflection valid values.

@return array


public function setValue($value): void
    {
        // If the value is not valid
        if (! static::isValid($value)) {
            // Throw an exception
            throw new InvalidArgumentException(
                sprintf(
                    'Invalid enumeration %s for Enum %s',
                    $value,
                    \get_class($this)
                )
            );
        }

        $this->value = $value;
    }

public
function
setValue
(
$
value
)
:
void
{
// If the value is not valid
if
(
!
static
::
isValid
(
$
value
)
)
{
// Throw an exception
throw
new
InvalidArgumentException
(
sprintf
(
'Invalid enumeration %s for Enum %s'
,
$
value
,
\
get_class
(
$
this
)
)
)
;
}
$
this
->
value
=
$
value
;
}

Set the enum value.

@param mixed $value The value to set

@throws \InvalidArgumentException

@return void


function init($xml, $fileattribs, $lastversion)
    {
        $this->_class = str_replace('/', '_', $fileattribs['name']);
        $this->_filename = $fileattribs['name'];
        $this->_class = str_replace ('.php', '', $this->_class) . '_postinstall';
        $this->_params = $xml;
        $this->_lastversion = $lastversion;
    }

function init ( $ xml , $ fileattribs , $ lastversion ) { $ this -> _class = str_replace ( '/' , '_' , $ fileattribs [ 'name' ] ) ; $ this -> _filename = $ fileattribs [ 'name' ] ; $ this -> _class = str_replace ( '.php' , '' , $ this -> _class ) . '_postinstall' ; $ this -> _params = $ xml ; $ this -> _lastversion = $ lastversion ; }

Initialize a task instance with the parameters
@param array raw, parsed xml
@param array attributes from the <file> tag containing this task
@param string|null last installed version of this package, if any (useful for upgrades)


function startSession($pkg, $contents)
    {
        if ($this->installphase != PEAR_TASK_INSTALL) {
            return false;
        }
        // remove the tasks: namespace if present
        $this->_pkg = $pkg;
        $this->_stripNamespace();
        $this->logger->log(0, 'Including external post-installation script "' .
            $contents . '" - any errors are in this script');
        include_once $contents;
        if (class_exists($this->_class)) {
            $this->logger->log(0, 'Inclusion succeeded');
        } else {
            return $this->throwError('init of post-install script class "' . $this->_class
                . '" failed');
        }
        $this->_obj = new $this->_class;
        $this->logger->log(1, 'running post-install script "' . $this->_class . '->init()"');
        PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
        $res = $this->_obj->init($this->config, $pkg, $this->_lastversion);
        PEAR::popErrorHandling();
        if ($res) {
            $this->logger->log(0, 'init succeeded');
        } else {
            return $this->throwError('init of post-install script "' . $this->_class .
                '->init()" failed');
        }
        $this->_contents = $contents;
        return true;
    }

Unlike other tasks, the installed file name is passed in instead of the file contents,
because this task is handled post-installation
@param PEAR_PackageFile_v1|PEAR_PackageFile_v2
@param string file name
@return bool|PEAR_Error false to skip this file, PEAR_Error to fail
(use $this->throwError)

Unlike other tasks the installed file name is passed in instead of the file contents because this task is handled post - installation


public function addSuccess($time)
    {
        $total = ( $this->data['avg'] * $this->data['works'] )  + $time;
        $this->data['works']++;
        $this->data['avg'] = $total/$this->data['works'];

        return $this->data['works'];
    }

public function addSuccess ( $ time ) { $ total = ( $ this -> data [ 'avg' ] * $ this -> data [ 'works' ] ) + $ time ; $ this -> data [ 'works' ] ++ ; $ this -> data [ 'avg' ] = $ total / $ this -> data [ 'works' ] ; return $ this -> data [ 'works' ] ; }

Record a success event

@param  integer $time mileseconds
@return integer Number of works succeed


public function addIdle()
    {
        $time = microtime(true) - $this->idleSince;
        $this->idleSince = microtime(true);

        return $this->data['idle'] += $time;
    }

public function addIdle ( ) { $ time = microtime ( true ) - $ this -> idleSince ; $ this -> idleSince = microtime ( true ) ; return $ this -> data [ 'idle' ] += $ time ; }

Record a idle event

@return integer Total time idle


public function getAmountEstimated()
    {
        $accountsVirtual = $this->getAllAccountsVirtual();

        $amount = 0.0;
        foreach ($accountsVirtual as $account) {
            $amount += $account->getAmount();
        }

        return ($this->getAmount() - $amount);
    }

public function getAmountEstimated ( ) { $ accountsVirtual = $ this -> getAllAccountsVirtual ( ) ; $ amount = 0.0 ; foreach ( $ accountsVirtual as $ account ) { $ amount += $ account -> getAmount ( ) ; } return ( $ this -> getAmount ( ) - $ amount ) ; }

Get amount estimated. It is real amount without virtual amounts.

@return float

Get amount estimated . It is real amount without virtual amounts .


public function getRequestMethods(): array
    {
        if (null === $this->requestMethods) {
            $this->requestMethods = [
                RequestMethod::GET,
                RequestMethod::HEAD,
            ];
        }

        return $this->requestMethods;
    }

public function getRequestMethods ( ) : array { if ( null === $ this -> requestMethods ) { $ this -> requestMethods = [ RequestMethod :: GET , RequestMethod :: HEAD , ] ; } return $ this -> requestMethods ; }


protected function disableWpAutoUpdate()
    {
        $this->wpMockery->addFilter('automatic_updater_disabled', '__return_true');

        $this->wpMockery->addFilter('allow_minor_auto_core_updates', '__return_false');
        $this->wpMockery->addFilter('allow_major_auto_core_updates', '__return_false');
        $this->wpMockery->addFilter('allow_dev_auto_core_updates', '__return_false');

        $this->wpMockery->addFilter('auto_update_core', '__return_false');
        $this->wpMockery->addFilter('wp_auto_update_core', '__return_false');
        $this->wpMockery->addFilter('send_core_update_notification_email', '__return_false');

        $this->wpMockery->addFilter('auto_update_translation', '__return_false');
        $this->wpMockery->addFilter('auto_core_update_send_email', '__return_false');
        $this->wpMockery->addFilter('auto_update_plugin', '__return_false');
        $this->wpMockery->addFilter('auto_update_theme', '__return_false');

        $this->wpMockery->addFilter('automatic_updates_send_debug_email', '__return_false');
        $this->wpMockery->addFilter('automatic_updates_is_vcs_checkout', '__return_true');
        $this->wpMockery->addFilter('automatic_updates_send_debug_email ', '__return_false', 1);

        if (!defined('AUTOMATIC_UPDATER_DISABLED')) {
            define('AUTOMATIC_UPDATER_DISABLED', true);
        }

        if (!defined('WP_AUTO_UPDATE_CORE')) {
            define('WP_AUTO_UPDATE_CORE', false);
        }
    }

protected
function
disableWpAutoUpdate
(
)
{
$
this
->
wpMockery
->
addFilter
(
'automatic_updater_disabled'
,
'__return_true'
)
;
$
this
->
wpMockery
->
addFilter
(
'allow_minor_auto_core_updates'
,
'__return_false'
)
;
$
this
->
wpMockery
->
addFilter
(
'allow_major_auto_core_updates'
,
'__return_false'
)
;
$
this
->
wpMockery
->
addFilter
(
'allow_dev_auto_core_updates'
,
'__return_false'
)
;
$
this
->
wpMockery
->
addFilter
(
'auto_update_core'
,
'__return_false'
)
;
$
this
->
wpMockery
->
addFilter
(
'wp_auto_update_core'
,
'__return_false'
)
;
$
this
->
wpMockery
->
addFilter
(
'send_core_update_notification_email'
,
'__return_false'
)
;
$
this
->
wpMockery
->
addFilter
(
'auto_update_translation'
,
'__return_false'
)
;
$
this
->
wpMockery
->
addFilter
(
'auto_core_update_send_email'
,
'__return_false'
)
;
$
this
->
wpMockery
->
addFilter
(
'auto_update_plugin'
,
'__return_false'
)
;
$
this
->
wpMockery
->
addFilter
(
'auto_update_theme'
,
'__return_false'
)
;
$
this
->
wpMockery
->
addFilter
(
'automatic_updates_send_debug_email'
,
'__return_false'
)
;
$
this
->
wpMockery
->
addFilter
(
'automatic_updates_is_vcs_checkout'
,
'__return_true'
)
;
$
this
->
wpMockery
->
addFilter
(
'automatic_updates_send_debug_email '
,
'__return_false'
,
1
)
;
if
(
!
defined
(
'AUTOMATIC_UPDATER_DISABLED'
)
)
{
define
(
'AUTOMATIC_UPDATER_DISABLED'
,
true
)
;
}
if
(
!
defined
(
'WP_AUTO_UPDATE_CORE'
)
)
{
define
(
'WP_AUTO_UPDATE_CORE'
,
false
)
;
}
}

Disable All Automatic Updates
3.7+

@author  sLa NGjI's @ slangji.wordpress.com


public function blockWpRequest($pre, $args, $url)
    {
        if (empty($url)) {
            return $pre;
        }

        /* Invalid host */
        if (!$host = $this->wpMockery->parseUrl($url, PHP_URL_HOST)) {
            return $pre;
        }

        $urlData = $this->wpMockery->parseUrl($url);

        /* block request */
        $path =  (false !== stripos($urlData['path'], 'update-check') || false !== stripos($urlData['path'], 'browse-happy'));

        if (false !== stripos($host, 'api.wordpress.org') && $path) {
            return true;
        }

        return $pre;
    }

public
function
blockWpRequest
(
$
pre
,
$
args
,
$
url
)
{
if
(
empty
(
$
url
)
)
{
return
$
pre
;
}
/* Invalid host */
if
(
!
$
host
=
$
this
->
wpMockery
->
parseUrl
(
$
url
,
PHP_URL_HOST
)
)
{
return
$
pre
;
}
$
urlData
=
$
this
->
wpMockery
->
parseUrl
(
$
url
)
;
/* block request */
$
path
=
(
false
!==
stripos
(
$
urlData
[
'path'
]
,
'update-check'
)
||
false
!==
stripos
(
$
urlData
[
'path'
]
,
'browse-happy'
)
)
;
if
(
false
!==
stripos
(
$
host
,
'api.wordpress.org'
)
&&
$
path
)
{
return
true
;
}
return
$
pre
;
}


protected function hideAdminNag()
    {
        if (!function_exists("remove_action")) {
            return;
        }

        /**
         * Hide maintenance and update nag
         */
        $this->wpMockery->removeAction('admin_notices', 'update_nag', 3);
        $this->wpMockery->removeAction('network_admin_notices', 'update_nag', 3);
        $this->wpMockery->removeAction('admin_notices', 'maintenance_nag');
        $this->wpMockery->removeAction('network_admin_notices', 'maintenance_nag');

        $this->wpMockery->removeAction('wp_maybe_auto_update', 'wp_maybe_auto_update');
        $this->wpMockery->removeAction('admin_init', 'wp_maybe_auto_update');
        $this->wpMockery->removeAction('admin_init', 'wp_auto_update_core');

        $this->wpMockery->wpClearScheduledHook('wp_maybe_auto_update');
    }


public function isValidPoint(PointInterface $a)
    {
        return (bool) (
            $this->getSegmentAB()->isValidPoint($a) ||
            $this->getSegmentBC()->isValidPoint($a) ||
            $this->getSegmentCD()->isValidPoint($a) ||
            $this->getSegmentDA()->isValidPoint($a)
        );
    }

public function isValidPoint ( PointInterface $ a ) { return ( bool ) ( $ this -> getSegmentAB ( ) -> isValidPoint ( $ a ) || $ this -> getSegmentBC ( ) -> isValidPoint ( $ a ) || $ this -> getSegmentCD ( ) -> isValidPoint ( $ a ) || $ this -> getSegmentDA ( ) -> isValidPoint ( $ a ) ) ; }

Test if point A is part of one of quadrilateral's segments

@param   \Maths\PointInterface   $a
@return  bool

Test if point A is part of one of quadrilateral s segments


public function isParallelogram()
    {
        $centerdiag1 = $this->getFirstDiagonal();
        $centerdiag2 = $this->getSecondDiagonal();
        return (bool) Maths::areSamePoint($centerdiag1->getCenter(), $centerdiag2->getCenter());
    }

public function isParallelogram ( ) { $ centerdiag1 = $ this -> getFirstDiagonal ( ) ; $ centerdiag2 = $ this -> getSecondDiagonal ( ) ; return ( bool ) Maths :: areSamePoint ( $ centerdiag1 -> getCenter ( ) , $ centerdiag2 -> getCenter ( ) ) ; }

Test if the quadrilateral is a parallelogram

@return  bool


public function get($composite_key, $default_value = null)
    {
        $array_keys = explode($this->separator, $composite_key);
        $container = $this->container;

        foreach ($array_keys as $key) {
            if (!$this->hasChild($container, $key)) {
                return $default_value;
            }
            $container = $this->getChild($container, $key);
        }
        return $container;
    }

public function get ( $ composite_key , $ default_value = null ) { $ array_keys = explode ( $ this -> separator , $ composite_key ) ; $ container = $ this -> container ; foreach ( $ array_keys as $ key ) { if ( ! $ this -> hasChild ( $ container , $ key ) ) { return $ default_value ; } $ container = $ this -> getChild ( $ container , $ key ) ; } return $ container ; }

Get multidimenional array value
@param string $composite_key concatenated keys with key separator
@param string $default_value to return in case that one key from chain is undefined


public function has($composite_key)
    {
        $array_keys = explode($this->separator, $composite_key);
        $container = $this->container;

        foreach ($array_keys as $key) {
            if (!$this->hasChild($container, $key)) {
                return false;
            }
            $container = $this->getChild($container, $key);
        }
        return true;
    }

public function has ( $ composite_key ) { $ array_keys = explode ( $ this -> separator , $ composite_key ) ; $ container = $ this -> container ; foreach ( $ array_keys as $ key ) { if ( ! $ this -> hasChild ( $ container , $ key ) ) { return false ; } $ container = $ this -> getChild ( $ container , $ key ) ; } return true ; }

Check if the last key from chain is defined
@param string $composite_key concatenated keys with key separator
@return Boolean


public function find($id)
    {
        $application = $this->repository->find($id);
        if (null == $application) {
            return null;
        }
        // Load tests
        $this->testLoader->loadByApplication($application);

        return $application;
    }

public
function
find
(
$
id
)
{
$
application
=
$
this
->
repository
->
find
(
$
id
)
;
if
(
==
$
application
)
{
return
;
}
// Load tests
$
this
->
testLoader
->
loadByApplication
(
$
application
)
;
return
$
application
;
}

Find an application

@param string $id App ID
@return Application


public function findAll()
    {
        $applications = array();
        foreach ($this->repository->findAll() as $application) {
            // Load tests
            $this->testLoader->loadByApplication($application);
            $applications[] = $application;
        }

        return $applications;
    }

public
function
findAll
(
)
{
$
applications
=
array
(
)
;
foreach
(
$
this
->
repository
->
findAll
(
)
as
$
application
)
{
// Load tests
$
this
->
testLoader
->
loadByApplication
(
$
application
)
;
$
applications
[
]
=
$
application
;
}
return
$
applications
;
}


public function equals(NumberSystem $comparedNumberSystem)
    {
        if ($this->getBase() !== $comparedNumberSystem->getBase() ||
            $this->getSymbolIndex() !== $comparedNumberSystem->getSymbolIndex()
        ) {
            return false;
        }

        return true;
    }

public function equals ( NumberSystem $ comparedNumberSystem ) { if ( $ this -> getBase ( ) !== $ comparedNumberSystem -> getBase ( ) || $ this -> getSymbolIndex ( ) !== $ comparedNumberSystem -> getSymbolIndex ( ) ) { return false ; } return true ; }

Compare two number systems.

@param NumberSystem $comparedNumberSystem

@return bool


public function getDigits(Number $number)
    {
        if (null === $this->delimiter) {
            return str_split($number->value());
        }

        return explode($this->delimiter, $number->value());
    }

public function getDigits ( Number $ number ) { if ( null === $ this -> delimiter ) { return str_split ( $ number -> value ( ) ) ; } return explode ( $ this -> delimiter , $ number -> value ( ) ) ; }

Get all digits of a given number according to
this number-system.

@param Number $number

@return array

Get all digits of a given number according to this number - system .


public function buildNumber(array $digits)
    {
        $newNumberString = implode($this->delimiter, $digits);

        return new Number($newNumberString, $this);
    }

public function buildNumber ( array $ digits ) { $ newNumberString = implode ( $ this -> delimiter , $ digits ) ; return new Number ( $ newNumberString , $ this ) ; }

Build a number based on given digits.

@param array $digits

@return Number


public function validateNumberValue($value)
    {
        if (null === $this->delimiter) {
            $parts = str_split($value);
        } else {
            $parts = explode($this->delimiter, $value);
        }

        foreach ($parts as $numberSymbol) {
            if (!$this->containsSymbol($numberSymbol)) {
                throw new NumberParseException($value, $numberSymbol);
            }
        }

        return true;
    }

public function validateNumberValue ( $ value ) { if ( null === $ this -> delimiter ) { $ parts = str_split ( $ value ) ; } else { $ parts = explode ( $ this -> delimiter , $ value ) ; } foreach ( $ parts as $ numberSymbol ) { if ( ! $ this -> containsSymbol ( $ numberSymbol ) ) { throw new NumberParseException ( $ value , $ numberSymbol ) ; } } return true ; }

Check if a string value is a valid number of this system.

@param string $value
@throws NumberParseException

@return bool

Check if a string value is a valid number of this system .


public function makeCall($name, array $arguments = [])
    {
        if (!$this->connected) {
            $this->_connect();
        }

        // ignore connect commands
        if (in_array($name, ['connect', 'pconnect'])) {
            return;
        }

        $log = true;
        switch (strtolower($name)) {
            case 'open':
            case 'popen':
            case 'close':
            case 'setoption':
            case 'getoption':
            case 'auth':
            case 'select':
                $log = false;
                break;
        }

        $ts     = microtime(true);
        $result = call_user_func_array('parent::'.$name, $arguments);
        $ts     = (microtime(true) - $ts) * 1000;

        $isError = false;
        if ($error = $this->getLastError()) {
            $this->clearLastError();
            $isError = true;
        }

        if ($log && null !== $this->logger) {
            $this->logger->logCommand($this->getCommandString($name, $arguments), $ts, $this->name, $isError);
        }

        if ($isError) {
            throw new PHPRedisCommunicationException('Redis command failed: '.$error);
        }

        return $result;
    }

public
function
makeCall
(
$
name
,
array
$
arguments
=
[
]
)
{
if
(
!
$
this
->
connected
)
{
$
this
->
_connect
(
)
;
}
// ignore connect commands
if
(
in_array
(
$
name
,
[
'connect'
,
'pconnect'
]
)
)
{
return
;
}
$
log
=
true
;
switch
(
strtolower
(
$
name
)
)
{
case
'open'
:
case
'popen'
:
case
'close'
:
case
'setoption'
:
case
'getoption'
:
case
'auth'
:
case
'select'
:
$
log
=
false
;
break
;
}
$
ts
=
microtime
(
true
)
;
$
result
=
call_user_func_array
(
'parent::'
.
$
name
,
$
arguments
)
;
$
ts
=
(
microtime
(
true
)
$
ts
)
*
1000
;
$
isError
=
false
;
if
(
$
error
=
$
this
->
getLastError
(
)
)
{
$
this
->
clearLastError
(
)
;
$
isError
=
true
;
}
if
(
$
log
&&
!==
$
this
->
logger
)
{
$
this
->
logger
->
logCommand
(
$
this
->
getCommandString
(
$
name
,
$
arguments
)
,
$
ts
,
$
this
->
name
,
$
isError
)
;
}
if
(
$
isError
)
{
throw
new
PHPRedisCommunicationException
(
'Redis command failed: '
.
$
error
)
;
}
return
$
result
;
}

wrap all redis calls to handle profiling

@param string $name      Redis method
@param array  $arguments Arguments to parse on the real method

@return boolean
@throws \InvalidArgumentException    If the command called does not exist
@throws PHPRedisCommunicationException If the call to redis fails


public function generateKey($kp)
    {
        $arguments = func_get_args();

        if (is_array($arguments[0])) {
            $arguments = $arguments[0];
        }

        return implode(':', $arguments);
    }

public function generateKey ( $ kp ) { $ arguments = func_get_args ( ) ; if ( is_array ( $ arguments [ 0 ] ) ) { $ arguments = $ arguments [ 0 ] ; } return implode ( ':' , $ arguments ) ; }

Generate cache key from method arguments.

Example:
<code>
// string arguments
$key = $redis->generateKey('some', 'part', 'of', 'key'); // returns: "some:part:of:key"

// array argument
$key = $redis->generateKey(['some', 'part', 'of', 'key']); // returns: "some:part:of:key"
</code>

@param string|array $kp,... List of parameters to use in key generation

@return string

Generate cache key from method arguments .


private function _connect($bailOnError = false)
    {
        $this->connected = $this->connect(
            $this->parameters['host'],
            $this->parameters['port'],
            ($this->parameters['timeout'] ?: 0)
        );

        if ($this->connected) {
            if ($this->parameters['auth']) {
                $this->auth($this->parameters['auth']);
            }

            if ($this->select($this->parameters['database'])) {
                // setup default options
                $this->setOption(\Redis::OPT_PREFIX, $this->parameters['prefix']);
                $this->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_PHP);

                return true;
            }
        } elseif (!$bailOnError) {
            // try to re-connect, but only once.
            usleep(1000);
            $this->_connect(true);
        }

        $error = $this->getLastError();
        $this->clearLastError();

        if ($this->logger) {
            $this->logger->err('Could not connect to redis server (' . $error . ')');
        }

        throw new PHPRedisCommunicationException('Could not connect to Redis: '.$error);
    }

private
function
_connect
(
$
bailOnError
=
false
)
{
$
this
->
connected
=
$
this
->
connect
(
$
this
->
parameters
[
'host'
]
,
$
this
->
parameters
[
'port'
]
,
(
$
this
->
parameters
[
'timeout'
]
:
0
)
)
;
if
(
$
this
->
connected
)
{
if
(
$
this
->
parameters
[
'auth'
]
)
{
$
this
->
auth
(
$
this
->
parameters
[
'auth'
]
)
;
}
if
(
$
this
->
select
(
$
this
->
parameters
[
'database'
]
)
)
{
// setup default options
$
this
->
setOption
(
\
Redis
::
OPT_PREFIX
,
$
this
->
parameters
[
'prefix'
]
)
;
$
this
->
setOption
(
\
Redis
::
OPT_SERIALIZER
,
\
Redis
::
SERIALIZER_PHP
)
;
return
true
;
}
}
elseif
(
!
$
bailOnError
)
{
// try to re-connect, but only once.
usleep
(
1000
)
;
$
this
->
_connect
(
true
)
;
}
$
error
=
$
this
->
getLastError
(
)
;
$
this
->
clearLastError
(
)
;
if
(
$
this
->
logger
)
{
$
this
->
logger
->
err
(
'Could not connect to redis server ('
.
$
error
.
')'
)
;
}
throw
new
PHPRedisCommunicationException
(
'Could not connect to Redis: '
.
$
error
)
;
}

handle connection management

@param boolean $bailOnError keeps track on connection retry

@return boolean
@throws PHPRedisCommunicationException If connection fails


private function getCommandString($command, array $arguments)
    {
        $list = [];
        foreach ($arguments as $argument) {
            $list[] = is_scalar($argument) ? $argument : '[.. complex type ..]';
        }

        return mb_substr(trim(strtoupper($command) . ' ' . $this->getPrefix() . implode(' ', $list)), 0, 256);
    }

private
function
getCommandString
(
$
command
,
array
$
arguments
)
{
$
list
=
[
]
;
foreach
(
$
arguments
as
$
argument
)
{
$
list
[
]
=
is_scalar
(
$
argument
)
$
argument
:
'[.. complex type ..]'
;
}
return
mb_substr
(
trim
(
strtoupper
(
$
command
)
.
' '
.
$
this
->
getPrefix
(
)
.
implode
(
' '
,
$
list
)
)
,
0
,
256
)
;
}

Returns a string representation of the given command including arguments

@param string $command   A command name
@param array  $arguments An array of command arguments

@return string


protected function getMongoDocument(DomainEventMessageInterface $domainEventMessage): array
    {
        $payload = $this
            ->getSerializer()
            ->serialize($domainEventMessage->getPayload());

        return [
            'aggregate_id' => $domainEventMessage->getAggregateId(),
            'sequence' => $domainEventMessage->getSequence(),
            'occurred_on' => new UTCDateTime(
                $domainEventMessage
                    ->getOccurredOn()
                    ->format('Uv')
            ),
            'payload' => [
                'name' => $payload->getClassName(),
                'data' => (object)$payload->getData(),
            ],
            'meta_data' => (object)$domainEventMessage->getMetaData(),
        ];
    }

protected function getMongoDocument ( DomainEventMessageInterface $ domainEventMessage ) : array { $ payload = $ this -> getSerializer ( ) -> serialize ( $ domainEventMessage -> getPayload ( ) ) ; return [ 'aggregate_id' => $ domainEventMessage -> getAggregateId ( ) , 'sequence' => $ domainEventMessage -> getSequence ( ) , 'occurred_on' => new UTCDateTime ( $ domainEventMessage -> getOccurredOn ( ) -> format ( 'Uv' ) ) , 'payload' => [ 'name' => $ payload -> getClassName ( ) , 'data' => ( object ) $ payload -> getData ( ) , ] , 'meta_data' => ( object ) $ domainEventMessage -> getMetaData ( ) , ] ; }

Get Mongo document from domain event message.

@param DomainEventMessageInterface $domainEventMessage
@return array
@throws SerializerException

Get Mongo document from domain event message .