Skip to content

Commit 14dafa3

Browse files
author
Andrey Helldar
committed
Added new public methods for App Version
1 parent 3b56f65 commit 14dafa3

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/Facades/AppVersion.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
* @method static bool is7x()
1313
* @method static bool is8x()
1414
* @method static bool is9x()
15+
* @method static int major()
16+
* @method static int minor()
17+
* @method static int patch()
18+
* @method static string version()
1519
*/
1620
class AppVersion extends Facade
1721
{

src/Support/AppVersion.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,26 @@ public function is9x(): bool
3030
return $this->major() === 9;
3131
}
3232

33-
protected function major(): int
33+
public function major(): int
3434
{
3535
return (int) Str::before($this->version(), '.');
3636
}
3737

38-
protected function version(): string
38+
public function minor(): int
39+
{
40+
$version = $this->parse();
41+
42+
return $version[1];
43+
}
44+
45+
public function patch(): int
46+
{
47+
$version = $this->parse();
48+
49+
return $version[2];
50+
}
51+
52+
public function version(): string
3953
{
4054
if (AppHelper::isLumen()) {
4155
preg_match('/.+\((\d+\.\d+\.\d+)\)/', app()->version(), $matches);
@@ -45,4 +59,9 @@ protected function version(): string
4559

4660
return Application::VERSION;
4761
}
62+
63+
protected function parse(): array
64+
{
65+
return explode('.', $this->version());
66+
}
4867
}

0 commit comments

Comments
 (0)