protected function createName() { $inputs[] = $this->table->getDatabase(); $inputs[] = $this->table->getCommonName(); $inputs[] = 'I'; $inputs[] = count($this->table->getIndices()) + 1; // @TODO replace the factory by a real object $this->name = NameFactory::generateName(NameFactory::CONSTRAINT_GENERATOR, $inputs); }
private function createName() { $table = $this->getTable(); $inputs = array(); $inputs[] = $table->getDatabase(); $inputs[] = $table->getCommonName(); if ($this->isUnique()) { $inputs[] = "U"; } else { $inputs[] = "I"; } // ASSUMPTION: This Index not yet added to the list. if ($this->isUnique()) { $inputs[] = count($table->getUnices()) + 1; } else { $inputs[] = count($table->getIndices()) + 1; } $this->indexName = NameFactory::generateName(NameFactory::CONSTRAINT_GENERATOR, $inputs); }
public function buildPhpName($name) { return NameFactory::generateName(NameFactory::PHP_GENERATOR, array($name, $this->phpNamingMethod)); }
/** * Returns a generated PHP name. * * @param string $name * @param string $phpNamingMethod * @param string $namePrefix * @return string */ public static function generatePhpName($name, $phpNamingMethod = PhpNameGenerator::CONV_METHOD_CLEAN, $namePrefix = null) { return NameFactory::generateName(NameFactory::PHP_GENERATOR, [$name, $phpNamingMethod, $namePrefix]); }
/** * Returns the auto generated PHP name value for a given name. * * @param string $name * @return string */ private function buildPhpName($name) { return NameFactory::generateName(NameFactory::PHP_GENERATOR, [$name, $this->phpNamingMethod]); }
/** * @throws Exception on fail */ public function testNames() { for ($algoIndex = 0; $algoIndex < count(self::$ALGORITHMS); $algoIndex++) { $algo = self::$ALGORITHMS[$algoIndex]; $algoInputs = self::$INPUTS[$algoIndex]; for ($i = 0; $i < count($algoInputs); $i++) { $inputs = $this->makeInputs($algo, $algoInputs[$i]); $generated = NameFactory::generateName($algo, $inputs); $expected = self::$OUTPUTS[$algoIndex][$i]; $this->assertEquals($expected, $generated, "Algorithm " . $algo . " failed to generate an unique name"); } } }