original_string: public function set(ItemInterface $item)
      {
          $id = $item->getId();
          $collectionName = $item->getCollection();
  
          $this->items[$id] = $item;
  
          if (isset($this->idCollections[$id]) && $this->idCollections[$id] !== $collectionName) {
              throw new \RuntimeException(sprintf('The item with id: "%s" has been registered previously with another collection.', $id));
          }
  
          if (isset($this->itemCollections[$collectionName]) === false) {
              $this->itemCollections[$collectionName] = [];
          }
  
          $this->itemCollections[$collectionName][$id] = $item;
          $this->idCollections[$id] = $collectionName;
      }
code: public function set(ItemInterface $item)
      {
          $id = $item->getId();
          $collectionName = $item->getCollection();
  
          $this->items[$id] = $item;
  
          if (isset($this->idCollections[$id]) && $this->idCollections[$id] !== $collectionName) {
              throw new \RuntimeException(sprintf('The item with id: "%s" has been registered previously with another collection.', $id));
          }
  
          if (isset($this->itemCollections[$collectionName]) === false) {
              $this->itemCollections[$collectionName] = [];
          }
  
          $this->itemCollections[$collectionName][$id] = $item;
          $this->idCollections[$id] = $collectionName;
      }
code_tokens: public function set ( ItemInterface $ item ) { $ id = $ item -> getId ( ) ; $ collectionName = $ item -> getCollection ( ) ; $ this -> items [ $ id ] = $ item ; if ( isset ( $ this -> idCollections [ $ id ] ) && $ this -> idCollections [ $ id ] !== $ collectionName ) { throw new \ RuntimeException ( sprintf ( 'The item with id: "%s" has been registered previously with another collection.' , $ id ) ) ; } if ( isset ( $ this -> itemCollections [ $ collectionName ] ) === false ) { $ this -> itemCollections [ $ collectionName ] = [ ] ; } $ this -> itemCollections [ $ collectionName ] [ $ id ] = $ item ; $ this -> idCollections [ $ id ] = $ collectionName ; }
docstring: Sets an item.
  
  @param Yosymfony\Spress\Core\DataSource\ItemInterface
  
  @throws \RuntimeException If the item has been registered previously in another collection
docstring_tokens: Sets an item .