Piwik\DataTable\Row::renameColumn PHP Méthode

renameColumn() public méthode

Renames a column.
public renameColumn ( string $oldName, string $newName )
$oldName string The current name of the column.
$newName string The new name of the column.
    public function renameColumn($oldName, $newName)
    {
        if (isset($this[$oldName])) {
            $this[$newName] = $this[$oldName];
        }
        // outside the if () since we want to delete nulled columns
        if ($this->offsetExists($oldName)) {
            unset($this[$oldName]);
        }
    }

Usage Example

Exemple #1
0
 public function test_renameColumn_shouldDoNothing_IfGivenColumnDoesNotExist()
 {
     $this->row->setColumn('nb_visits', 11);
     $this->row->renameColumn('nb_hits', 'nb_pageviews');
     $this->assertFalse($this->row->hasColumn('nb_hits'));
     $this->assertFalse($this->row->hasColumn('nb_pageviews'));
     $this->assertEquals(11, $this->row->getColumn('nb_visits'));
 }
All Usage Examples Of Piwik\DataTable\Row::renameColumn