src/Config/Proxy.php
protected function parseSomething(
        $module,
        $param,
        $default,
        callable $parser,
        $origin,
        callable $checker
    ) {
        try {
            if (!isset($this->modules[$module])) {
                throw new \Erebot\NotFoundException('No such module');
            }
            $value  = $this->modules[$module]->getParam($param);
            $value  = $parser($value);
            if ($value !== null) {
                return $value;
            }
            throw new \Erebot\InvalidValueException(
                'Bad value in configuration'
            );
        } catch (\Erebot\NotFoundException $e) {
            if ($this->proxified !== $this) {
                return $this->proxified->$origin($module, $param, $default);
            }

            if ($default === null) {
                throw new \Erebot\NotFoundException('No such parameter "' .
                                                    $param . '" for module "' .
                                                    $module . '"');
            }

            if ($checker($default)) {
                return $default;
            }
            throw new \Erebot\InvalidValueException('Bad default value');
        }
    }
protected function parseSomething(
        $module,
        $param,
        $default,
        callable $parser,
        $origin,
        callable $checker
    ) {
        try {
            if (!isset($this->modules[$module])) {
                throw new \Erebot\NotFoundException('No such module');
            }
            $value  = $this->modules[$module]->getParam($param);
            $value  = $parser($value);
            if ($value !== null) {
                return $value;
            }
            throw new \Erebot\InvalidValueException(
                'Bad value in configuration'
            );
        } catch (\Erebot\NotFoundException $e) {
            if ($this->proxified !== $this) {
                return $this->proxified->$origin($module, $param, $default);
            }

            if ($default === null) {
                throw new \Erebot\NotFoundException('No such parameter "' .
                                                    $param . '" for module "' .
                                                    $module . '"');
            }

            if ($checker($default)) {
                return $default;
            }
            throw new \Erebot\InvalidValueException('Bad default value');
        }
    }
protected function parseSomething ( $ module , $ param , $ default , callable $ parser , $ origin , callable $ checker ) { try { if ( ! isset ( $ this -> modules [ $ module ] ) ) { throw new \ Erebot \ NotFoundException ( 'No such module' ) ; } $ value = $ this -> modules [ $ module ] -> getParam ( $ param ) ; $ value = $ parser ( $ value ) ; if ( $ value !== null ) { return $ value ; } throw new \ Erebot \ InvalidValueException ( 'Bad value in configuration' ) ; } catch ( \ Erebot \ NotFoundException $ e ) { if ( $ this -> proxified !== $ this ) { return $ this -> proxified -> $ origin ( $ module , $ param , $ default ) ; } if ( $ default === null ) { throw new \ Erebot \ NotFoundException ( 'No such parameter "' . $ param . '" for module "' . $ module . '"' ) ; } if ( $ checker ( $ default ) ) { return $ default ; } throw new \ Erebot \ InvalidValueException ( 'Bad default value' ) ; } }
Returns the typed value for a module's parameter.

\param string $module
The name of the module.

\param string $param
The name of the parameter to fetch
from the module's settings.

\param mixed $default
Default value if no value has been
defined in the module's settings,
or \b null if there is no default value.

\param callable $parser
Object that will be used to parse the parameter.
It will receive the value of that parameter as a
string and should convert it to the proper type.

\param string $origin
Name of the method the request to parse
the parameter originated from.

\param callable $checker
Object that will be passed the parsed value
and should return \b true if it respects the
type constraints defined by this checker,
or \b false if it does not.

\retval mixed
Value as parsed from the module's settings,
or the default value if no value existed in
the settings and it passed the type check.

\throw Erebot::InvalidValueException
The value parsed or the default value did not
pass the type check.

\throw Erebot::NotFoundException
Returns the typed value for a module s parameter .