Passed
Push — 4.x ( b027a1...820cf2 )
by Kit Loong
62:09
created

CheckLaravelVersion::atLeastLaravelVersion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: liow.kitloong
5
 * Date: 2021/01/02
6
 */
7
8
namespace KitLoong\MigrationsGenerator\Support;
9
10
use Illuminate\Support\Facades\App;
11
12
trait CheckLaravelVersion
13
{
14
    public function atLeastLaravel5Dot7(): bool
15
    {
16
        return $this->atLeastLaravelVersion('5.7.0');
17
    }
18
19
    public function atLeastLaravel5Dot8(): bool
20
    {
21
        return $this->atLeastLaravelVersion('5.8.0');
22
    }
23
24
    public function atLeastLaravel6(): bool
25
    {
26
        return $this->atLeastLaravelVersion('6.0');
27
    }
28
29
    public function atLeastLaravel7(): bool
30
    {
31
        return $this->atLeastLaravelVersion('7.0');
32
    }
33
34
    public function atLeastLaravel8(): bool
35
    {
36
        return $this->atLeastLaravelVersion('8.0');
37
    }
38
39
    private function atLeastLaravelVersion(string $version): bool
40
    {
41
        return version_compare(App::version(), $version, '>=');
0 ignored issues
show
Bug Best Practice introduced by
The expression return version_compare(I...sion(), $version, '>=') could return the type integer which is incompatible with the type-hinted return boolean. Consider adding an additional type-check to rule them out.
Loading history...
42
    }
43
}
44