MigrationVersion::getVersionByName PHP Method

getVersionByName() public method

Will return a version based in the migration name
public getVersionByName ( array $mapping ) : boolean | string
$mapping array mapping of all migrations.
return boolean | string
    public function getVersionByName($mapping)
    {
        $version = false;
        foreach ($mapping as $key => $info) {
            if ($mapping[$key]['name'] == $this->jumpTo) {
                $version = $key;
            }
        }
        return $version;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * TestGetVersionByName method
  *
  * @return void
  */
 public function testGetVersionByName()
 {
     $Version = new MigrationVersion(array('jumpTo' => '007_schema_dump'));
     $result = $Version->getVersionByName($this->_mapping());
     $this->assertEquals(7, $result);
     $Version = new MigrationVersion(array('jumpTo' => '00_schema_dump'));
     $result = $Version->getVersionByName($this->_mapping());
     $this->assertFalse($result);
 }