21
vendor/jean85/pretty-package-versions/LICENSE
vendored
Normal file
21
vendor/jean85/pretty-package-versions/LICENSE
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Alessandro Lai
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
1
vendor/jean85/pretty-package-versions/codecov.yml
vendored
Normal file
1
vendor/jean85/pretty-package-versions/codecov.yml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
comment: false
|
||||
43
vendor/jean85/pretty-package-versions/composer.json
vendored
Normal file
43
vendor/jean85/pretty-package-versions/composer.json
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "jean85/pretty-package-versions",
|
||||
"description": "A wrapper for ocramius/package-versions to get pretty versions strings",
|
||||
"type": "library",
|
||||
"require": {
|
||||
"php": "^7.0",
|
||||
"composer/package-versions-deprecated": "^1.8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6.0"
|
||||
},
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Alessandro Lai",
|
||||
"email": "alessandro.lai85@gmail.com"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/Jean85/pretty-package-versions/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"package",
|
||||
"versions",
|
||||
"composer",
|
||||
"release"
|
||||
],
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Jean85\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Tests\\": "tests"
|
||||
}
|
||||
}
|
||||
}
|
||||
25
vendor/jean85/pretty-package-versions/src/PrettyVersions.php
vendored
Normal file
25
vendor/jean85/pretty-package-versions/src/PrettyVersions.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Jean85;
|
||||
|
||||
use PackageVersions\Versions;
|
||||
|
||||
class PrettyVersions
|
||||
{
|
||||
const SHORT_COMMIT_LENGTH = 7;
|
||||
|
||||
public static function getVersion(string $packageName): Version
|
||||
{
|
||||
return new Version($packageName, Versions::getVersion($packageName));
|
||||
}
|
||||
|
||||
public static function getRootPackageName(): string
|
||||
{
|
||||
return Versions::ROOT_PACKAGE_NAME;
|
||||
}
|
||||
|
||||
public static function getRootPackageVersion(): Version
|
||||
{
|
||||
return self::getVersion(Versions::ROOT_PACKAGE_NAME);
|
||||
}
|
||||
}
|
||||
73
vendor/jean85/pretty-package-versions/src/Version.php
vendored
Normal file
73
vendor/jean85/pretty-package-versions/src/Version.php
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace Jean85;
|
||||
|
||||
class Version
|
||||
{
|
||||
const SHORT_COMMIT_LENGTH = PrettyVersions::SHORT_COMMIT_LENGTH;
|
||||
|
||||
/** @var string */
|
||||
private $packageName;
|
||||
|
||||
/** @var string */
|
||||
private $shortVersion;
|
||||
|
||||
/** @var string */
|
||||
private $commitHash;
|
||||
|
||||
/** @var bool */
|
||||
private $versionIsTagged;
|
||||
|
||||
public function __construct(string $packageName, string $version)
|
||||
{
|
||||
$this->packageName = $packageName;
|
||||
$splittedVersion = explode('@', $version);
|
||||
$this->shortVersion = $splittedVersion[0];
|
||||
$this->commitHash = $splittedVersion[1];
|
||||
$this->versionIsTagged = preg_match('/[^v\d\.]/', $this->getShortVersion()) === 0;
|
||||
}
|
||||
|
||||
public function getPrettyVersion(): string
|
||||
{
|
||||
if ($this->versionIsTagged) {
|
||||
return $this->getShortVersion();
|
||||
}
|
||||
|
||||
return $this->getVersionWithShortCommit();
|
||||
}
|
||||
|
||||
public function getFullVersion(): string
|
||||
{
|
||||
return $this->getShortVersion() . '@' . $this->getCommitHash();
|
||||
}
|
||||
|
||||
public function getVersionWithShortCommit(): string
|
||||
{
|
||||
return $this->getShortVersion() . '@' . $this->getShortCommitHash();
|
||||
}
|
||||
|
||||
public function getPackageName(): string
|
||||
{
|
||||
return $this->packageName;
|
||||
}
|
||||
|
||||
public function getShortVersion(): string
|
||||
{
|
||||
return $this->shortVersion;
|
||||
}
|
||||
|
||||
public function getCommitHash(): string
|
||||
{
|
||||
return $this->commitHash;
|
||||
}
|
||||
|
||||
public function getShortCommitHash(): string
|
||||
{
|
||||
return substr($this->commitHash, 0, self::SHORT_COMMIT_LENGTH);
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->getPrettyVersion();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user