AbstractObject::learn PHP Method

learn() public method

Similar to memorize, but if value for key exist, will return it.
public learn ( string $key, mixed $default = null ) : mixed
$key string Data Key
$default mixed Default value
return mixed Previously memorized data or $default
    public function learn($key, $default = null)
    {
        /** @type App_Web $this->app */
        if (!session_id()) {
            $this->app->initializeSession(false);
        }
        if (!isset($_SESSION['o'][$this->name][$key]) || is_null($_SESSION['o'][$this->name][$key])) {
            if (is_callable($default)) {
                $default = call_user_func($default);
            }
            return $this->memorize($key, $default);
        } else {
            return $this->recall($key);
        }
    }