Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
"ramsey/uuid": "^3.7|^4.0",
"symfony/var-dumper": "^4.0|^5.0"
},
"require-dev": {
"laravel/framework": "^6.0|^7.0|^8.0",
"laravel/lumen-framework": "^6.0|^7.0|^8.0"
},
"conflict": {
"andrey-helldar/laravel-support": "*"
},
Expand Down
21 changes: 21 additions & 0 deletions src/Facades/AppVersion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace DragonCode\LaravelSupport\Facades;

use DragonCode\LaravelSupport\Support\AppVersion as Support;
use Illuminate\Support\Facades\Facade;

/**
* @method static bool is6x()
* @method static bool is7x()
* @method static bool is8x()
*/
class AppVersion extends Facade
{
protected static function getFacadeAccessor(): string
{
return Support::class;
}
}
46 changes: 46 additions & 0 deletions src/Support/AppVersion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

declare(strict_types=1);

namespace DragonCode\LaravelSupport\Support;

use DragonCode\LaravelSupport\Facades\App as AppHelper;
use Illuminate\Foundation\Application;
use Illuminate\Support\Str;

class AppVersion
{
public function is6x(): bool
{
return $this->major() === 6;
}

public function is7x(): bool
{
return $this->major() === 7;
}

public function is8x(): bool
{
return $this->major() === 8;
}

protected function major(): int
{
return (int) Str::before($this->version(), '.');
}

protected function version(): string
{
if (AppHelper::isLumen()) {
$version = app()->version();

$version = Str::after($version, '(');
$version = Str::before($version, ')');

return $version;
}

return Application::VERSION;
}
}