public function testGettingClassNameFromFile() { $classDir = '/var/www/public/ci306/application/migrations'; $file = $classDir . '/m0001_Initial.php'; $this->assertEquals('m0001_Initial', ClassHelper::getClassNameFromFile($file, $classDir)); }
/** * Returns a list of all model names in lowercase or false if not models were found. * * @return array|bool * * @throws ClassNotFoundException * * @since 1.1.0 * * @author Eddilbert Macharia (http://eddmash.com) <*****@*****.**> */ public function getModelClasses() { $models = []; $modelFiles = $this->getModelFiles(); if (empty($modelFiles)) { return false; } $namespace = BaseOrm::getModelsNamespace(); foreach ($this->getModelFiles() as $file) { $className = ClassHelper::getClassNameFromFile($file, BaseOrm::getModelsPath()); $foundClass = ClassHelper::classExists($className, $namespace); if (!$foundClass) { throw new ClassNotFoundException(sprintf('The class [ %1$s\\%2$s or \\%1$s ] could not be located', $className, $namespace)); } $models[] = $foundClass; } return $models; }
/** * @return array * * @throws ClassNotFoundException * * @since 1.1.0 * * @author Eddilbert Macharia (http://eddmash.com) <*****@*****.**> */ public function getMigrationsClasses() { $migrationFiles = $this->getMigrationsFiles(); $classes = []; $namespace = BaseOrm::getMigrationsNamespace(); foreach ($migrationFiles as $migrationFile) { $className = ClassHelper::getClassNameFromFile($migrationFile, BaseOrm::getMigrationsPath()); $foundClass = ClassHelper::classExists($className, $namespace); if (!$className) { throw new ClassNotFoundException(sprintf('The class [ %2$s\\%1$s or \\%1$s ] could not be located', $className, $namespace)); } $classes[] = $foundClass; } return $classes; }