PHP code example of aybarsm / laravel-extended-support
1. Go to this page and download the library: Download aybarsm/laravel-extended-support library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
aybarsm / laravel-extended-support example snippets
use Aybarsm\Laravel\Support\Supplements\Str\SemVer;
use Aybarsm\Laravel\Support\Enums\SemVerScope;
// Regardless of multiple occurrences, the function always captures the first occurrence of \d+\.\d+\.\d+
$version = 'ver9.2.78beta-1.0.6';
$semVer = new SemVer($version);
$semVer = Str::semVer($version);
// Get scope of the Semantic Version:
dump($semVer->getScope(SemVerScope::MINOR)); // Output: "2"
dump($semVer->getScope(SemVerScope::MINOR, $asInteger = true)); // Output: 2
// More importantly you can easily calculate the next scopes of the Semantic Version.
dump($semVer->value()); // Output: "9.2.78"
$semVer = $semVer->next(SemVerScope::MINOR);
dump($semVer->value()); // Output: "9.3.0"
$semVer = $semVer->next(SemVerScope::PATCH);
dump($semVer->value()); // Output: "9.3.1"
$semVer = $semVer->next(SemVerScope::MAJOR);
dump($semVer->value()); // Output: "10.0.0"
// You can access the original Semantic Version by:
dump($semVer->getOriginal()); // Output: "9.2.78"
// If you would like to have an output with t original version structure
dump($semVer->value($asOriginal = true)); // Output: "ver10.0.0beta-1.0.6"
// Lastly, static function and Str macros have been implemented to validate Semantic Version string.
SemVer::validate('9.2.78'); // Output: true
// OR
Str::isSemVer('9.2'); // Output: false
use Aybarsm\Laravel\Support\Traits\EnumHelper;
enum ProcessReturnType: int
{
use EnumHelper;
case STATUS = 0;
case SUCCESSFUL = 1;
case FAILED = 2;
case EXIT_CODE = 3;
case OUTPUT = 4;
case ERROR_OUTPUT = 5;
case INSTANCE = 6;
case ALL_OUTPUT = 7;
}
$enum = ProcessReturnType::tryFrom(ProcessReturnType::byName('EXIT_CODE')); //returns designated enum as static