public function add(string $dir): self
    {
        $dir = rtrim(\BearFramework\Internal\Utilities::normalizePath($dir), '/') . '/';
        if (!isset($this->dirs[$dir])) {
            $this->dirs[$dir] = strlen($dir);
            arsort($this->dirs);
            $indexFilename = $dir . 'index.php';
            if (is_file($indexFilename)) {
                ob_start();
                try {
                    (static function($__filename) {
                        include $__filename;
                    })($indexFilename);
                    ob_end_clean();
                } catch (\Exception $e) {
                    ob_end_clean();
                    throw $e;
                }
            } else {
                throw new \Exception('Cannot find index.php file in the dir specified (' . $dir . ')!');
            }
        }
        return $this;
    }
public function add(string $dir): self
    {
        $dir = rtrim(\BearFramework\Internal\Utilities::normalizePath($dir), '/') . '/';
        if (!isset($this->dirs[$dir])) {
            $this->dirs[$dir] = strlen($dir);
            arsort($this->dirs);
            $indexFilename = $dir . 'index.php';
            if (is_file($indexFilename)) {
                ob_start();
                try {
                    (static function($__filename) {
                        include $__filename;
                    })($indexFilename);
                    ob_end_clean();
                } catch (\Exception $e) {
                    ob_end_clean();
                    throw $e;
                }
            } else {
                throw new \Exception('Cannot find index.php file in the dir specified (' . $dir . ')!');
            }
        }
        return $this;
    }
public function add ( string $ dir ) : self { $ dir = rtrim ( \ BearFramework \ Internal \ Utilities :: normalizePath ( $ dir ) , '/' ) . '/' ; if ( ! isset ( $ this -> dirs [ $ dir ] ) ) { $ this -> dirs [ $ dir ] = strlen ( $ dir ) ; arsort ( $ this -> dirs ) ; $ indexFilename = $ dir . 'index.php' ; if ( is_file ( $ indexFilename ) ) { ob_start ( ) ; try { ( static function ( $ __filename ) { include $ __filename ; } ) ( $ indexFilename ) ; ob_end_clean ( ) ; } catch ( \ Exception $ e ) { ob_end_clean ( ) ; throw $ e ; } } else { throw new \ Exception ( 'Cannot find index.php file in the dir specified (' . $ dir . ')!' ) ; } } return $ this ; }
Registers a new context.

@param string $dir The context dir.
@throws \Exception
@return self Returns a reference to itself.
Registers a new context .