public function rename($oldName, $newName)
    {
        if (null !== $this->collection->get($newName)) {
            throw new RuntimeException(
                sprintf(
                    'Could not rename toggle %1$s to %2$s, a toggle with name %2$s already exists',
                    $oldName,
                    $newName
                )
            );
        }

        $currentToggle = $this->collection->get($oldName);

        if (null === $currentToggle) {
            throw new RuntimeException(
                sprintf(
                    'Could not rename toggle %1$s to %2$s, toggle with name %1$s does not exists',
                    $oldName,
                    $newName
                )
            );
        }

        $currentToggle->rename($newName);

        if (false === $this->add($currentToggle)) {
            throw new RuntimeException(
                sprintf(
                    'Failed to rename toggle %1$s to %2$s, an error occurred when saving toggle with new name',
                    $oldName,
                    $newName
                )
            );
        }

        return $this->remove($oldName);
    }
public function rename($oldName, $newName)
    {
        if (null !== $this->collection->get($newName)) {
            throw new RuntimeException(
                sprintf(
                    'Could not rename toggle %1$s to %2$s, a toggle with name %2$s already exists',
                    $oldName,
                    $newName
                )
            );
        }

        $currentToggle = $this->collection->get($oldName);

        if (null === $currentToggle) {
            throw new RuntimeException(
                sprintf(
                    'Could not rename toggle %1$s to %2$s, toggle with name %1$s does not exists',
                    $oldName,
                    $newName
                )
            );
        }

        $currentToggle->rename($newName);

        if (false === $this->add($currentToggle)) {
            throw new RuntimeException(
                sprintf(
                    'Failed to rename toggle %1$s to %2$s, an error occurred when saving toggle with new name',
                    $oldName,
                    $newName
                )
            );
        }

        return $this->remove($oldName);
    }
public function rename ( $ oldName , $ newName ) { if ( null !== $ this -> collection -> get ( $ newName ) ) { throw new RuntimeException ( sprintf ( 'Could not rename toggle %1$s to %2$s, a toggle with name %2$s already exists' , $ oldName , $ newName ) ) ; } $ currentToggle = $ this -> collection -> get ( $ oldName ) ; if ( null === $ currentToggle ) { throw new RuntimeException ( sprintf ( 'Could not rename toggle %1$s to %2$s, toggle with name %1$s does not exists' , $ oldName , $ newName ) ) ; } $ currentToggle -> rename ( $ newName ) ; if ( false === $ this -> add ( $ currentToggle ) ) { throw new RuntimeException ( sprintf ( 'Failed to rename toggle %1$s to %2$s, an error occurred when saving toggle with new name' , $ oldName , $ newName ) ) ; } return $ this -> remove ( $ oldName ) ; }
Rename the toggle.

@param string $oldName
@param string $newName

@throws RuntimeException

@return bool
Rename the toggle .