Compare commits
2 commits
acdb06f766
...
942f8a4bde
| Author | SHA1 | Date | |
|---|---|---|---|
| 942f8a4bde | |||
| 82346bc36f |
2 changed files with 16 additions and 5 deletions
8
bin/cfg
8
bin/cfg
|
|
@ -22,7 +22,7 @@ foreach ($autoloadFiles as $autoloadFile) {
|
|||
}
|
||||
}
|
||||
|
||||
$version = '0.2';
|
||||
$version = '0.3';
|
||||
|
||||
$actions = [ 'show', 'write', 'help' ];
|
||||
$settings = ['key' => '', 'value' => ''];
|
||||
|
|
@ -158,7 +158,7 @@ try {
|
|||
exit(0);
|
||||
}
|
||||
}
|
||||
echo $ex->getMessage().PHP_EOL;
|
||||
fwrite(STDERR, $ex->getMessage().PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -204,7 +204,7 @@ try {
|
|||
$cfg->load(require($cfgFile));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo "Error: ".$e->getMessage()."\n";
|
||||
fwrite(STDERR, "Error: ".$e->getMessage().PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
//var_dump($cfg);
|
||||
|
|
@ -220,7 +220,7 @@ if ($settings['key'])
|
|||
$result = $result->{$setting};
|
||||
}
|
||||
catch (\OutOfRangeException $e) {
|
||||
echo $e->getMessage().PHP_EOL;
|
||||
fwrite(STDERR, $e->getMessage().PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace rabe\Util;
|
|||
* Settings Class to read Configuration Files
|
||||
* @author Norbert.e.Wagner dev@norb.me
|
||||
*/
|
||||
class Settings implements \Iterator
|
||||
class Settings implements \Iterator, \Countable
|
||||
{
|
||||
private const SITE = 0x01;
|
||||
|
||||
|
|
@ -314,6 +314,17 @@ class Settings implements \Iterator
|
|||
|
||||
// }}}
|
||||
|
||||
// Countable {{{
|
||||
/**
|
||||
* Count elements
|
||||
* @link https://www.php.net/countable.count.php
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
count($this->settings);
|
||||
}
|
||||
// }}}
|
||||
|
||||
// Magic getter/setter methods {{{
|
||||
public function __set( $name, $value )
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue