1
<?php
2

3
namespace Nuwave\Lighthouse\Support;
4

5
use Illuminate\Support\Str;
6

7
class AppVersion
8
{
9 1
    public static function isLumen(): bool
10
    {
11 1
        return Str::contains(self::version(), 'Lumen');
12
    }
13

14 1
    public static function atLeast(float $version): bool
15
    {
16 1
        return self::versionNumber() >= $version;
17
    }
18

19 1
    public static function below(float $version): bool
20
    {
21 1
        return self::versionNumber() < $version;
22
    }
23

24 1
    protected static function version(): string
25
    {
26 1
        return app()->version();
27
    }
28

29 1
    protected static function versionNumber(): float
30
    {
31 1
        if (self::isLumen()) {
32
            // Lumen version strings look like: "Lumen (2.3.4)..."
33 0
            return (float) Str::after(self::version(), '(');
34
        }
35

36
        // Regular Laravel versions look like: "2.3.4"
37 1
        return (float) self::version();
38
    }
39
}

Read our documentation on viewing source code .

Loading