Библиотека для cis, online, cms1

This commit is contained in:
Фёдор Подлеснов 2016-06-29 18:51:32 +03:00
commit 3c2e614d87
269 changed files with 39854 additions and 0 deletions

100
core/collection.php Normal file
View file

@ -0,0 +1,100 @@
<?php
/**
* Êîëëåêöèÿ
*
* package core
*/
class Collection implements ArrayAccess
{
/**
* Holds collective request data
*
* @var array
*/
protected $data = array();
/**
* Ïðåîáðàçîâàíèå ìàññèâà â êîëëåêöèþ
*
* @param array $data
*/
public function import(array $data)
{
$this->data = array_merge($this->data, $data);
return true;
}
/**
* Ïðåîáðàçîâàíèå êîëëåêöèè â ìàññèâ
*/
public function export()
{
return $this->data;
}
/**
* Store "request data" in GPC order.
*
* @param string $key
* @param mixed $value
*
* @return void
*/
public function set($key, $value)
{
$this->data[$key] = $value;
}
/**
* Read stored "request data" by referencing a key.
*
* @param string $key
*
* @return mixed
*/
public function get($key, $default = null)
{
return isset($this->data[$key]) ? $this->data[$key] : $default;
}
public function getInt($key, $default = 0)
{
return intval($this->get($key, $default));
}
public function getString($key, $default = '')
{
return ((string) $this->get($key, $default));
}
public function getNat($key, $default = 1)
{
$result = intval($this->get($key, $default));
return (($result > 0) ? $result : $default);
}
public function clear()
{
$this->data = array();
}
public function offsetSet($key, $value)
{
$this->data[$key] = $value;
}
public function offsetExists($key)
{
return isset($this->data[$key]);
}
public function offsetUnset($key)
{
unset($this->data[$key]);
}
public function offsetGet($key)
{
return isset($this->data[$key]) ? $this->data[$key] : null;
}
}