File tree 1 file changed +5
-22
lines changed
1 file changed +5
-22
lines changed Original file line number Diff line number Diff line change 6
6
7
7
class Version
8
8
{
9
- private const COMPOSER_PATHS = [
10
- 'composer.json ' ,
11
- '../composer.json ' ,
12
- '../../composer.json ' ,
13
- '../../../composer.json ' ,
14
- './vendor/phparkitect/phparkitect/composer.json ' ,
15
- ];
16
-
17
9
public static function get (): string
18
10
{
19
11
$ pharPath = \Phar::running ();
20
12
21
13
if ($ pharPath ) {
22
14
$ content = file_get_contents ("$ pharPath/composer.json " );
23
- $ composerData = json_decode ( $ content , true );
24
-
25
- return $ composerData [ ' version ' ] ?? ' UNKNOWN ' ;
15
+ } else {
16
+ $ phparkitectRootPath = __DIR__ . ' /../../ ' ;
17
+ $ content = file_get_contents ( $ phparkitectRootPath . ' composer.json ' ) ;
26
18
}
27
19
28
- foreach (self ::COMPOSER_PATHS as $ composerPath ) {
29
- if (!file_exists ($ composerPath )) {
30
- continue ;
31
- }
32
-
33
- $ content = file_get_contents ($ composerPath );
34
- $ composerData = json_decode ($ content , true );
35
-
36
- return $ composerData ['version ' ] ?? 'UNKNOWN ' ;
37
- }
20
+ $ composerData = json_decode ($ content , true );
38
21
39
- return 'UNKNOWN ' ;
22
+ return $ composerData [ ' version ' ] ?? 'UNKNOWN ' ;
40
23
}
41
24
}
You can’t perform that action at this time.
0 commit comments