"Fossies" - the Fresh Open Source Software Archive

Member "phpunit-9.0.1/src/Runner/Version.php" (13 Feb 2020, 1309 Bytes) of package /linux/www/phpunit-9.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Version.php" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 9.0.0_vs_9.0.1.

    1 <?php declare(strict_types=1);
    2 /*
    3  * This file is part of PHPUnit.
    4  *
    5  * (c) Sebastian Bergmann <sebastian@phpunit.de>
    6  *
    7  * For the full copyright and license information, please view the LICENSE
    8  * file that was distributed with this source code.
    9  */
   10 namespace PHPUnit\Runner;
   11 
   12 use SebastianBergmann\Version as VersionId;
   13 
   14 final class Version
   15 {
   16     /**
   17      * @var string
   18      */
   19     private static $pharVersion = '';
   20 
   21     /**
   22      * @var string
   23      */
   24     private static $version = '';
   25 
   26     /**
   27      * Returns the current version of PHPUnit.
   28      */
   29     public static function id(): string
   30     {
   31         if (self::$pharVersion !== '') {
   32             return self::$pharVersion;
   33         }
   34 
   35         if (self::$version === '') {
   36             self::$version = (new VersionId('9.0.1', \dirname(__DIR__, 2)))->getVersion();
   37         }
   38 
   39         return self::$version;
   40     }
   41 
   42     public static function series(): string
   43     {
   44         if (\strpos(self::id(), '-')) {
   45             $version = \explode('-', self::id())[0];
   46         } else {
   47             $version = self::id();
   48         }
   49 
   50         return \implode('.', \array_slice(\explode('.', $version), 0, 2));
   51     }
   52 
   53     public static function getVersionString(): string
   54     {
   55         return 'PHPUnit ' . self::id() . ' by Sebastian Bergmann and contributors.';
   56     }
   57 }