update config

This commit is contained in:
DavidBadura 2015-04-07 21:37:13 +00:00
parent 081e90ede2
commit ec3976e39a
1 changed files with 32 additions and 2 deletions

View File

@ -5,7 +5,7 @@ namespace DavidBadura\Taskwarrior;
/**
* @author David Badura <d.a.badura@gmail.com>
*/
class Config
class Config implements \IteratorAggregate, \Countable
{
/**
* @var array
@ -42,11 +42,35 @@ class Config
/**
* @return array
*/
public function toArray()
public function keys()
{
return array_keys($this->config);
}
/**
* @return array
*/
public function all()
{
return $this->config;
}
/**
* @return \ArrayIterator
*/
public function getIterator()
{
return new \ArrayIterator($this->config);
}
/**
* @return int
*/
public function count()
{
return count($this->config);
}
/**
* @param string $string
* @return array
@ -64,6 +88,12 @@ class Config
list($key, $value) = explode('=', $line);
if ($value == 'no' || $value == 'off') {
$value = false;
} elseif ($value == 'yes' || $value == 'on') {
$value = true;
}
$config[$key] = $value;
}