mirror of
https://github.com/pierre42100/comunic
synced 2025-06-21 09:35:19 +00:00
First commit
This commit is contained in:
66
developer/vendor/rockettheme/toolbox/ArrayTraits/src/ArrayAccess.php
vendored
Normal file
66
developer/vendor/rockettheme/toolbox/ArrayTraits/src/ArrayAccess.php
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
namespace RocketTheme\Toolbox\ArrayTraits;
|
||||
|
||||
/**
|
||||
* Implements ArrayAccess interface.
|
||||
*
|
||||
* @package RocketTheme\Toolbox\ArrayTraits
|
||||
* @author RocketTheme
|
||||
* @license MIT
|
||||
*
|
||||
* @property array $items
|
||||
*/
|
||||
trait ArrayAccess
|
||||
{
|
||||
/**
|
||||
* Whether or not an offset exists.
|
||||
*
|
||||
* @param mixed $offset An offset to check for.
|
||||
* @return bool Returns TRUE on success or FALSE on failure.
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return isset($this->items[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value at specified offset.
|
||||
*
|
||||
* @param mixed $offset The offset to retrieve.
|
||||
* @return mixed Can return all value types.
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return isset($this->items[$offset]) ? $this->items[$offset] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns a value to the specified offset.
|
||||
*
|
||||
* @param mixed $offset The offset to assign the value to.
|
||||
* @param mixed $value The value to set.
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if (is_null($offset)) {
|
||||
$this->items[] = $value;
|
||||
} else {
|
||||
$this->items[$offset] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets an offset.
|
||||
*
|
||||
* @param mixed $offset The offset to unset.
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
// Hack to make Iterator trait work together with unset.
|
||||
if (isset($this->iteratorUnset) && $offset == key($this->items)) {
|
||||
$this->iteratorUnset = true;
|
||||
}
|
||||
|
||||
unset($this->items[$offset]);
|
||||
}
|
||||
}
|
57
developer/vendor/rockettheme/toolbox/ArrayTraits/src/ArrayAccessWithGetters.php
vendored
Normal file
57
developer/vendor/rockettheme/toolbox/ArrayTraits/src/ArrayAccessWithGetters.php
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
namespace RocketTheme\Toolbox\ArrayTraits;
|
||||
|
||||
/**
|
||||
* Implements getters and setters.
|
||||
*
|
||||
* @package RocketTheme\Toolbox\ArrayTraits
|
||||
* @author RocketTheme
|
||||
* @license MIT
|
||||
*/
|
||||
trait ArrayAccessWithGetters
|
||||
{
|
||||
use ArrayAccess;
|
||||
|
||||
/**
|
||||
* Magic setter method
|
||||
*
|
||||
* @param mixed $offset Asset name value
|
||||
* @param mixed $value Asset value
|
||||
*/
|
||||
public function __set($offset, $value)
|
||||
{
|
||||
$this->offsetSet($offset, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter method
|
||||
*
|
||||
* @param mixed $offset Asset name value
|
||||
* @return mixed Asset value
|
||||
*/
|
||||
public function __get($offset)
|
||||
{
|
||||
return $this->offsetGet($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method to determine if the attribute is set
|
||||
*
|
||||
* @param mixed $offset Asset name value
|
||||
* @return boolean True if the value is set
|
||||
*/
|
||||
public function __isset($offset)
|
||||
{
|
||||
return $this->offsetExists($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method to unset the attribute
|
||||
*
|
||||
* @param mixed $offset The name value to unset
|
||||
*/
|
||||
public function __unset($offset)
|
||||
{
|
||||
$this->offsetUnset($offset);
|
||||
}
|
||||
}
|
24
developer/vendor/rockettheme/toolbox/ArrayTraits/src/Constructor.php
vendored
Normal file
24
developer/vendor/rockettheme/toolbox/ArrayTraits/src/Constructor.php
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace RocketTheme\Toolbox\ArrayTraits;
|
||||
|
||||
/**
|
||||
* Implements Constructor for setting items.
|
||||
*
|
||||
* @package RocketTheme\Toolbox\ArrayTraits
|
||||
* @author RocketTheme
|
||||
* @license MIT
|
||||
*
|
||||
* @property array $items
|
||||
*/
|
||||
trait Constructor
|
||||
{
|
||||
/**
|
||||
* Constructor to initialize array.
|
||||
*
|
||||
* @param array $items Initial items inside the iterator.
|
||||
*/
|
||||
public function __construct(array $items = array())
|
||||
{
|
||||
$this->items = $items;
|
||||
}
|
||||
}
|
24
developer/vendor/rockettheme/toolbox/ArrayTraits/src/Countable.php
vendored
Normal file
24
developer/vendor/rockettheme/toolbox/ArrayTraits/src/Countable.php
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace RocketTheme\Toolbox\ArrayTraits;
|
||||
|
||||
/**
|
||||
* Implements \Countable interface.
|
||||
*
|
||||
* @package RocketTheme\Toolbox\ArrayTraits
|
||||
* @author RocketTheme
|
||||
* @license MIT
|
||||
*
|
||||
* @property array $items
|
||||
*/
|
||||
trait Countable
|
||||
{
|
||||
/**
|
||||
* Implements Countable interface.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return count($this->items);
|
||||
}
|
||||
}
|
51
developer/vendor/rockettheme/toolbox/ArrayTraits/src/Export.php
vendored
Normal file
51
developer/vendor/rockettheme/toolbox/ArrayTraits/src/Export.php
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
namespace RocketTheme\Toolbox\ArrayTraits;
|
||||
|
||||
use Symfony\Component\Yaml\Exception\DumpException;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
/**
|
||||
* Implements ExportInterface.
|
||||
*
|
||||
* @package RocketTheme\Toolbox\ArrayTraits
|
||||
* @author RocketTheme
|
||||
* @license MIT
|
||||
*
|
||||
* @property array $items
|
||||
*/
|
||||
trait Export
|
||||
{
|
||||
/**
|
||||
* Convert object into an array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert object into YAML string.
|
||||
*
|
||||
* @param int $inline The level where you switch to inline YAML.
|
||||
* @param int $indent The amount of spaces to use for indentation of nested nodes.
|
||||
*
|
||||
* @return string A YAML string representing the object.
|
||||
* @throws DumpException
|
||||
*/
|
||||
public function toYaml($inline = 3, $indent = 2)
|
||||
{
|
||||
return Yaml::dump($this->toArray(), $inline, $indent, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert object into JSON string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toJson()
|
||||
{
|
||||
return json_encode($this->toArray());
|
||||
}
|
||||
}
|
35
developer/vendor/rockettheme/toolbox/ArrayTraits/src/ExportInterface.php
vendored
Normal file
35
developer/vendor/rockettheme/toolbox/ArrayTraits/src/ExportInterface.php
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace RocketTheme\Toolbox\ArrayTraits;
|
||||
|
||||
/**
|
||||
* Defines Export interface.
|
||||
*
|
||||
* @package RocketTheme\Toolbox\ArrayTraits
|
||||
* @author RocketTheme
|
||||
* @license MIT
|
||||
*/
|
||||
interface ExportInterface
|
||||
{
|
||||
/**
|
||||
* Convert object into an array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray();
|
||||
|
||||
/**
|
||||
* Convert object into YAML string.
|
||||
*
|
||||
* @param int $inline
|
||||
* @param int $indent
|
||||
* @return string
|
||||
*/
|
||||
public function toYaml($inline = 3, $indent = 2);
|
||||
|
||||
/**
|
||||
* Convert object into JSON string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toJson();
|
||||
}
|
77
developer/vendor/rockettheme/toolbox/ArrayTraits/src/Iterator.php
vendored
Normal file
77
developer/vendor/rockettheme/toolbox/ArrayTraits/src/Iterator.php
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
namespace RocketTheme\Toolbox\ArrayTraits;
|
||||
|
||||
/**
|
||||
* Implements \Iterator interface.
|
||||
*
|
||||
* @package RocketTheme\Toolbox\ArrayTraits
|
||||
* @author RocketTheme
|
||||
* @license MIT
|
||||
*
|
||||
* @property array $items
|
||||
*/
|
||||
trait Iterator
|
||||
{
|
||||
/**
|
||||
* Hack to make Iterator work together with unset().
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $iteratorUnset = false;
|
||||
|
||||
/**
|
||||
* Returns the current element.
|
||||
*
|
||||
* @return mixed Can return any type.
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
return current($this->items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key of the current element.
|
||||
*
|
||||
* @return mixed Returns scalar on success, or NULL on failure.
|
||||
*/
|
||||
public function key()
|
||||
{
|
||||
return key($this->items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the current position to the next element.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
if ($this->iteratorUnset) {
|
||||
// If current item was unset, position is already in the next element (do nothing).
|
||||
$this->iteratorUnset = false;
|
||||
} else {
|
||||
next($this->items);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewinds back to the first element of the Iterator.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function rewind()
|
||||
{
|
||||
$this->iteratorUnset = false;
|
||||
reset($this->items);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called after Iterator::rewind() and Iterator::next() to check if the current position is valid.
|
||||
*
|
||||
* @return bool Returns TRUE on success or FALSE on failure.
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return key($this->items) !== null;
|
||||
}
|
||||
}
|
190
developer/vendor/rockettheme/toolbox/ArrayTraits/src/NestedArrayAccess.php
vendored
Normal file
190
developer/vendor/rockettheme/toolbox/ArrayTraits/src/NestedArrayAccess.php
vendored
Normal file
@ -0,0 +1,190 @@
|
||||
<?php
|
||||
namespace RocketTheme\Toolbox\ArrayTraits;
|
||||
|
||||
/**
|
||||
* Implements nested ArrayAccess interface with dot notation.
|
||||
*
|
||||
* @package RocketTheme\Toolbox\ArrayTraits
|
||||
* @author RocketTheme
|
||||
* @license MIT
|
||||
*
|
||||
* @property array $items
|
||||
*/
|
||||
trait NestedArrayAccess
|
||||
{
|
||||
protected $nestedSeparator = '.';
|
||||
|
||||
/**
|
||||
* Get value by using dot notation for nested arrays/objects.
|
||||
*
|
||||
* @example $value = $this->get('this.is.my.nested.variable');
|
||||
*
|
||||
* @param string $name Dot separated path to the requested value.
|
||||
* @param mixed $default Default value (or null).
|
||||
* @param string $separator Separator, defaults to '.'
|
||||
* @return mixed Value.
|
||||
*/
|
||||
public function get($name, $default = null, $separator = null)
|
||||
{
|
||||
$path = explode($separator ?: $this->nestedSeparator, $name);
|
||||
$current = $this->items;
|
||||
foreach ($path as $field) {
|
||||
if (is_object($current) && isset($current->{$field})) {
|
||||
$current = $current->{$field};
|
||||
} elseif (is_array($current) && isset($current[$field])) {
|
||||
$current = $current[$field];
|
||||
} else {
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
|
||||
return $current;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value by using dot notation for nested arrays/objects.
|
||||
*
|
||||
* @example $data->set('this.is.my.nested.variable', $value);
|
||||
*
|
||||
* @param string $name Dot separated path to the requested value.
|
||||
* @param mixed $value New value.
|
||||
* @param string $separator Separator, defaults to '.'
|
||||
* @return $this
|
||||
*/
|
||||
public function set($name, $value, $separator = null)
|
||||
{
|
||||
$path = explode($separator ?: $this->nestedSeparator, $name);
|
||||
$current = &$this->items;
|
||||
foreach ($path as $field) {
|
||||
if (is_object($current)) {
|
||||
// Handle objects.
|
||||
if (!isset($current->{$field})) {
|
||||
$current->{$field} = array();
|
||||
}
|
||||
$current = &$current->{$field};
|
||||
} else {
|
||||
// Handle arrays and scalars.
|
||||
if (!is_array($current)) {
|
||||
$current = array($field => array());
|
||||
} elseif (!isset($current[$field])) {
|
||||
$current[$field] = array();
|
||||
}
|
||||
$current = &$current[$field];
|
||||
}
|
||||
}
|
||||
|
||||
$current = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset value by using dot notation for nested arrays/objects.
|
||||
*
|
||||
* @example $data->undef('this.is.my.nested.variable');
|
||||
*
|
||||
* @param string $name Dot separated path to the requested value.
|
||||
* @param string $separator Separator, defaults to '.'
|
||||
* @return $this
|
||||
*/
|
||||
public function undef($name, $separator = null)
|
||||
{
|
||||
if ($name === '') {
|
||||
$this->items = [];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$path = explode($separator ?: $this->nestedSeparator, $name);
|
||||
$var = array_pop($path);
|
||||
$current = &$this->items;
|
||||
|
||||
foreach ($path as $field) {
|
||||
if (is_object($current)) {
|
||||
// Handle objects.
|
||||
if (!isset($current->{$field})) {
|
||||
return $this;
|
||||
}
|
||||
$current = &$current->{$field};
|
||||
} else {
|
||||
// Handle arrays and scalars.
|
||||
if (!is_array($current) || !isset($current[$field])) {
|
||||
return $this;
|
||||
}
|
||||
$current = &$current[$field];
|
||||
}
|
||||
}
|
||||
|
||||
unset($current[$var]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default value by using dot notation for nested arrays/objects.
|
||||
*
|
||||
* @example $data->def('this.is.my.nested.variable', 'default');
|
||||
*
|
||||
* @param string $name Dot separated path to the requested value.
|
||||
* @param mixed $default Default value (or null).
|
||||
* @param string $separator Separator, defaults to '.'
|
||||
* @return $this
|
||||
*/
|
||||
public function def($name, $default = null, $separator = null)
|
||||
{
|
||||
$this->set($name, $this->get($name, $default, $separator), $separator);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not an offset exists.
|
||||
*
|
||||
* @param mixed $offset An offset to check for.
|
||||
* @return bool Returns TRUE on success or FALSE on failure.
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return $this->get($offset) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value at specified offset.
|
||||
*
|
||||
* @param mixed $offset The offset to retrieve.
|
||||
* @return mixed Can return all value types.
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return $this->get($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns a value to the specified offset.
|
||||
*
|
||||
* @param mixed $offset The offset to assign the value to.
|
||||
* @param mixed $value The value to set.
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if (is_null($offset)) {
|
||||
$this->items[] = $value;
|
||||
} else {
|
||||
$this->set($offset, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets variable at specified offset.
|
||||
*
|
||||
* @param $offset
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
if (is_null($offset)) {
|
||||
$this->items[] = [];
|
||||
} else {
|
||||
$this->undef($offset);
|
||||
}
|
||||
}
|
||||
}
|
57
developer/vendor/rockettheme/toolbox/ArrayTraits/src/NestedArrayAccessWithGetters.php
vendored
Normal file
57
developer/vendor/rockettheme/toolbox/ArrayTraits/src/NestedArrayAccessWithGetters.php
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
namespace RocketTheme\Toolbox\ArrayTraits;
|
||||
|
||||
/**
|
||||
* Implements getters and setters.
|
||||
*
|
||||
* @package RocketTheme\Toolbox\ArrayTraits
|
||||
* @author RocketTheme
|
||||
* @license MIT
|
||||
*/
|
||||
trait NestedArrayAccessWithGetters
|
||||
{
|
||||
use NestedArrayAccess;
|
||||
|
||||
/**
|
||||
* Magic setter method
|
||||
*
|
||||
* @param mixed $offset Asset name value
|
||||
* @param mixed $value Asset value
|
||||
*/
|
||||
public function __set($offset, $value)
|
||||
{
|
||||
$this->offsetSet($offset, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter method
|
||||
*
|
||||
* @param mixed $offset Asset name value
|
||||
* @return mixed Asset value
|
||||
*/
|
||||
public function __get($offset)
|
||||
{
|
||||
return $this->offsetGet($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method to determine if the attribute is set
|
||||
*
|
||||
* @param mixed $offset Asset name value
|
||||
* @return boolean True if the value is set
|
||||
*/
|
||||
public function __isset($offset)
|
||||
{
|
||||
return $this->offsetExists($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method to unset the attribute
|
||||
*
|
||||
* @param mixed $offset The name value to unset
|
||||
*/
|
||||
public function __unset($offset)
|
||||
{
|
||||
$this->offsetUnset($offset);
|
||||
}
|
||||
}
|
34
developer/vendor/rockettheme/toolbox/ArrayTraits/src/Serializable.php
vendored
Normal file
34
developer/vendor/rockettheme/toolbox/ArrayTraits/src/Serializable.php
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace RocketTheme\Toolbox\ArrayTraits;
|
||||
|
||||
/**
|
||||
* Implements \Serializable interface.
|
||||
*
|
||||
* @package RocketTheme\Toolbox\ArrayTraits
|
||||
* @author RocketTheme
|
||||
* @license MIT
|
||||
*
|
||||
* @property array $items
|
||||
*/
|
||||
trait Serializable
|
||||
{
|
||||
/**
|
||||
* Returns string representation of the object.
|
||||
*
|
||||
* @return string Returns the string representation of the object.
|
||||
*/
|
||||
public function serialize()
|
||||
{
|
||||
return serialize($this->items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called during unserialization of the object.
|
||||
*
|
||||
* @param string $serialized The string representation of the object.
|
||||
*/
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
$this->items = unserialize($serialized);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user