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 src/Facades/AppVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
* @method static bool is7x()
* @method static bool is8x()
* @method static bool is9x()
* @method static int major()
* @method static int minor()
* @method static int patch()
* @method static string version()
*/
class AppVersion extends Facade
{
Expand Down
23 changes: 21 additions & 2 deletions src/Support/AppVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,26 @@ public function is9x(): bool
return $this->major() === 9;
}

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

protected function version(): string
public function minor(): int
{
$version = $this->parse();

return $version[1];
}

public function patch(): int
{
$version = $this->parse();

return $version[2];
}

public function version(): string
{
if (AppHelper::isLumen()) {
preg_match('/.+\((\d+\.\d+\.\d+)\)/', app()->version(), $matches);
Expand All @@ -45,4 +59,9 @@ protected function version(): string

return Application::VERSION;
}

protected function parse(): array
{
return explode('.', $this->version());
}
}