class Utils

Contains a number of utilities facilitating development (are not to be included into code packages).

<?php

class Utils
{

/**
* Set up salt for hash
* @param string $salt
*/
static public function setSalt($salt)

/**
* Reindex the array using the nested array field
* as a key; it is used for sorting
* sets of strings returned by the database
* @param string $key
* @param array $data
* @throws Exception
* @return array
*/
static public function rekey($key , array $data)

/**
* Query the array using the nested array fields
* as keys and values; it is used for filtering
* set of strings returned by the database
* @param string $keyField
* @param string $valueField
* @param array $data
* @return array
*/
static public function collectData($keyField , $valueField, $data)

/**
* Choose a column from the array; it is used for filtering
* set of strings returned by the database
* @param string $key
* @param array $data
* @throws Exception
* @return array
*/
static public function fetchCol($key , array $data)

/**
* Group the array strings (nested subarrays) using
* nested array field s a key; it is used for
* for sorting the sets of strings returned by the database
* @param string $key
* @param array $data
* @return array
*/
static public function groupByKey($key , array $data)

/**
* Get hash from string
* @param string $string
* @throws Exception
* @return string
*/
static public function hash($string)

/**
* Format file size
* @param integer $size - byte
* @return string
*/
static public function formatFileSize($size)

/**
* Format time difference;
* it’s used for counter display.
* @param integer $difference
* @return string
*/
static public function formatTime($difference)

/**
* Export PHP array to file
* The function may return Boolean FALSE, however, it may also return a non-boolean value,
* which may be interpreted as FALSE.
* Use operator === to compare the values returned
* by the function.
* @param string $file
* @param string $string
* @return integer / false
*/
static public function exportArray($file , array $data)

/**
* Export PHP code to file;
* The function may return Boolean FALSE, however, it may also return a non-boolean value,
* which may be interpreted as FALSE.
* Use operator === to compare the values returned
* by the function.
* @param string $file
* @param string $string
* @return integer / false
*/
static public function exportCode($file , $string)

/**
* Get class name by the path
* @param string $path
* @return string or false
*/
static public function classFromPath($path)

/**
* Create a path to cache; it splits the file name into subdirectories,
* adding them to the main path
* @param string $basePath — cache main directory
* @param string $fileName — file name
* @return string
*/
static public function createCachePath($basePath , $fileName)

/**
* Convert the list of file paths into a Tree object
* @param array $data
* @return Tree
*/
static public function fileListToTree(array $data)

/**
* Get a random string
* @param integer $length — string length
* @return string
*/
static function getRandomString($length)

/**
* Check if the application is running
* in Windows OS
* @return boolean
*/
static function isWindows()
}

comments powered by Disqus