Initial commit

This commit is contained in:
2017-02-13 02:53:48 +01:00
commit b347a8e22b
25 changed files with 1449 additions and 0 deletions

61
src/PropertyList.php Normal file
View File

@@ -0,0 +1,61 @@
<?php
namespace NoccyLabs\PulseAudio;
use ArrayAccess;
use IteratorAggregate;
use Countable;
class PropertyList implements ArrayAccess, IteratorAggregate, Countable
{
protected $properties = [];
protected $readOnly = false;
public function __construct(array $properties=[], $readOnly=false)
{
$this->properties = $properties;
$this->readOnly = $readOnly;
}
public function getIterator()
{
return new ArrayIterator($this->properties);
}
public function offsetGet($key)
{
if (!array_key_exist($key, $this->properties)) {
throw new InvalidArgumentException("No such property: {$key}");
}
return $this->properties[$key];
}
public function offsetSet($key, $value)
{
if ($this->readOnly) {
return;
}
$this->properties[$key] = $value;
}
public function offsetUnset($key)
{
if ($this->readOnly) {
return;
}
unset($this->properties[$key]);
}
public function offsetExists($key)
{
return array_key_exists($key, $this->properties);
}
public function count()
{
return count($this->properties);
}
}