original_string: public function add(string $id): self
      {
          if (!isset($this->data[$id])) {
              $registeredAddon = \BearFramework\Addons::get($id);
              if ($registeredAddon === null) {
                  throw new \Exception('The addon ' . $id . ' is not registered!');
              }
              $registeredAddonOptions = $registeredAddon->options;
              if (isset($registeredAddonOptions['require']) && is_array($registeredAddonOptions['require'])) {
                  foreach ($registeredAddonOptions['require'] as $requiredAddonID) {
                      if (is_string($requiredAddonID) && !isset($this->data[$requiredAddonID])) {
                          $this->add($requiredAddonID);
                      }
                  }
              }
  
              $dir = $registeredAddon->dir;
              $this->data[$id] = new \BearFramework\App\Addon($id, $dir);
              $this->app->contexts->add($dir);
          }
          return $this;
      }
code: public function add(string $id): self
      {
          if (!isset($this->data[$id])) {
              $registeredAddon = \BearFramework\Addons::get($id);
              if ($registeredAddon === null) {
                  throw new \Exception('The addon ' . $id . ' is not registered!');
              }
              $registeredAddonOptions = $registeredAddon->options;
              if (isset($registeredAddonOptions['require']) && is_array($registeredAddonOptions['require'])) {
                  foreach ($registeredAddonOptions['require'] as $requiredAddonID) {
                      if (is_string($requiredAddonID) && !isset($this->data[$requiredAddonID])) {
                          $this->add($requiredAddonID);
                      }
                  }
              }
  
              $dir = $registeredAddon->dir;
              $this->data[$id] = new \BearFramework\App\Addon($id, $dir);
              $this->app->contexts->add($dir);
          }
          return $this;
      }
code_tokens: public function add ( string $ id ) : self { if ( ! isset ( $ this -> data [ $ id ] ) ) { $ registeredAddon = \ BearFramework \ Addons :: get ( $ id ) ; if ( $ registeredAddon === null ) { throw new \ Exception ( 'The addon ' . $ id . ' is not registered!' ) ; } $ registeredAddonOptions = $ registeredAddon -> options ; if ( isset ( $ registeredAddonOptions [ 'require' ] ) && is_array ( $ registeredAddonOptions [ 'require' ] ) ) { foreach ( $ registeredAddonOptions [ 'require' ] as $ requiredAddonID ) { if ( is_string ( $ requiredAddonID ) && ! isset ( $ this -> data [ $ requiredAddonID ] ) ) { $ this -> add ( $ requiredAddonID ) ; } } } $ dir = $ registeredAddon -> dir ; $ this -> data [ $ id ] = new \ BearFramework \ App \ Addon ( $ id , $ dir ) ; $ this -> app -> contexts -> add ( $ dir ) ; } return $ this ; }
docstring: Enables an addon.
  
  @param string $id The id of the addon.
  @throws \Exception
  @return self Returns a reference to itself.
docstring_tokens: Enables an addon .