original_string: public function addPackage($name, $location = null, $main = null)
      {
          $name = (string)$name;
  
          if ($name == '') {
              throw new exception\InvalidArgumentException('The require.js package name must not be empty');
          }
  
          if (!$location && !$main) {
              $this->packages[$name] = $name;
              return $this;
          }
  
          $this->packages[$name] = [
              'name' => $name,
          ];
  
          if ($location) {
              $this->packages[$name]['location'] = (string)$location;
          }
  
          if ($main) {
              $this->packages[$name]['main'] = (string)$main;
          }
  
          return $this;
      }
code: public function addPackage($name, $location = null, $main = null)
      {
          $name = (string)$name;
  
          if ($name == '') {
              throw new exception\InvalidArgumentException('The require.js package name must not be empty');
          }
  
          if (!$location && !$main) {
              $this->packages[$name] = $name;
              return $this;
          }
  
          $this->packages[$name] = [
              'name' => $name,
          ];
  
          if ($location) {
              $this->packages[$name]['location'] = (string)$location;
          }
  
          if ($main) {
              $this->packages[$name]['main'] = (string)$main;
          }
  
          return $this;
      }
code_tokens: public function addPackage ( $ name , $ location = null , $ main = null ) { $ name = ( string ) $ name ; if ( $ name == '' ) { throw new exception \ InvalidArgumentException ( 'The require.js package name must not be empty' ) ; } if ( ! $ location && ! $ main ) { $ this -> packages [ $ name ] = $ name ; return $ this ; } $ this -> packages [ $ name ] = [ 'name' => $ name , ] ; if ( $ location ) { $ this -> packages [ $ name ] [ 'location' ] = ( string ) $ location ; } if ( $ main ) { $ this -> packages [ $ name ] [ 'main' ] = ( string ) $ main ; } return $ this ; }
docstring: Add a package definition.
  
  If the package is already defined it will be replaced.
  
  @see http://requirejs.org/docs/api.html#packages
  @param string $name
  @param string $location
  @param string $main
docstring_tokens: Add a package definition .