Пример #1
0
 /**
  * Verify that a string is trimmed or throw an Exception.
  *
  * @since 0.1.0
  *
  * @param string $string The string to validate.
  *
  * @return string The validated string.
  * @throws InvalidArgumentException If the string is not trimmed.
  */
 public static function validateTrimmed($string)
 {
     if (SetupHelper::trim($string) === $string) {
         return (string) $string;
     }
     throw new InvalidArgumentException(sprintf('Provided string "%1$s" was not trimmed.', $string));
 }
Пример #2
0
 /**
  * Verify that a string is in lowercase or throw an Exception.
  *
  * @param string $string The string to validate.
  *
  * @return string The validated string.
  * @throws Exception\InvalidArgumentException If the string is not in lowercase
  */
 public static function validateLowerCase($string)
 {
     if ($string === Scripts\SetupHelper::getLowerCase($string)) {
         return $string;
     }
     return parent::validateLowerCase($string);
 }
 /**
  * Get the target path for a rendered file from a template file.
  *
  * @since 0.1.0
  *
  * @param string $pathname The path and file name to the template file.
  *
  * @return string The target path and file name to use for the rendered file.
  */
 protected function getTargetPath($pathname)
 {
     $filesystem = new Filesystem();
     $templatesFolder = $this->getConfigKey('Folders', 'templates');
     $folderDiff = '/' . $filesystem->findShortestPath(SetupHelper::getRootFolder(), $templatesFolder);
     return (string) $this->removeTemplateExtension(str_replace($folderDiff, '', $pathname));
 }
 /**
  * Complete the setup task.
  *
  * @since 0.1.0
  *
  * @return void
  */
 public function complete()
 {
     $filesystem = new Filesystem();
     foreach ($this->getRootFiles() as $file) {
         try {
             $filesystem->remove(SetupHelper::getFile($file));
         } catch (Exception $exception) {
             $this->io->writeError(sprintf('Could not remove file "%1$s". Reason: %2$s', SetupHelper::getFile($file), $exception->getMessage()));
         }
     }
 }
Пример #5
0
    return Validation::validatePascalCase($placeholder);
}, 'default' => function ($placeholders) {
    return SetupHelper::getPascalCase($placeholders['Vendor']['value']);
}], 'vendor' => ['name' => 'Vendor name in lowercase', 'description' => 'The vendor name of the package in "lowercase" (no spaces, each word starting with a lower case letter).', 'validation' => function ($placeholder) {
    return Validation::validateLowerCase($placeholder);
}, 'default' => function ($placeholders) {
    return SetupHelper::getLowerCase($placeholders['VendorPC']['value']);
}], 'Package' => ['name' => 'Package name', 'description' => 'The name of the package.', 'validation' => function ($placeholder) {
    return Validation::validateTrimmed($placeholder);
}, 'default' => 'Package Name'], 'PackagePC' => ['name' => 'Package name in PascalCase', 'description' => 'The package name of the package in "PascalCase" (no spaces, each word starting with a capital).', 'validation' => function ($placeholder) {
    return Validation::validatePascalCase($placeholder);
}, 'default' => function ($placeholders) {
    return SetupHelper::getPascalCase($placeholders['Package']['value']);
}], 'package' => ['name' => 'Package name in lowercase', 'description' => 'The package name of the package in "lowercase" (no spaces, each word starting with a lower case letter).', 'validation' => function ($placeholder) {
    return Validation::validateLowerCase($placeholder);
}, 'default' => function ($placeholders) {
    return SetupHelper::getLowerCase($placeholders['PackagePC']['value']);
}], 'description' => ['name' => 'Package description', 'description' => 'The package description in one sentence.', 'validation' => function ($placeholder) {
    return Validation::validateTrimmed($placeholder);
}, 'default' => 'TODO: Describe what this package is all about.'], 'author' => ['name' => 'Author name', 'description' => 'The name of the author of the package.', 'validation' => function ($placeholder) {
    return Validation::validateTrimmed($placeholder);
}, 'default' => 'Alain Schlesser'], 'email' => ['name' => 'Author email', 'description' => 'The email of the author.', 'validation' => function ($placeholder) {
    return Validation::validateEmail($placeholder);
}, 'default' => '*****@*****.**'], 'url' => ['name' => 'Author URL', 'description' => 'The website of the author or the package.', 'validation' => function ($placeholder) {
    return Validation::validateURL($placeholder);
}, 'default' => 'https://www.brightnucleus.com/'], 'year' => ['name' => 'Copyright year', 'description' => 'The year for which the copyright is displayed. Can include a range of years as well.', 'validation' => function ($placeholder) {
    return Validation::validateYear($placeholder);
}, 'default' => date('Y')], 'date' => ['name' => 'Date', 'description' => 'Date to be used for first change log entry.', 'validation' => function ($placeholder) {
    return Validation::validateDate($placeholder);
}, 'default' => date('Y-m-d')]];
return ['BrightNucleus' => ['Boilerplate' => ['Folders' => $folders, 'Placeholders' => $placeholders, 'TemplateExtension' => '.template']]];