• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Cecilapp / Cecil / 5046041481

pending completion
5046041481

Pull #1697

github

GitHub
Merge 2cd309b47 into a16355c73
Pull Request #1697: perf: native_function_invocation

322 of 322 new or added lines in 62 files covered. (100.0%)

2784 of 4121 relevant lines covered (67.56%)

0.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

6.25
/src/Util/Plateform.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of Cecil.
7
 *
8
 * Copyright (c) Arnaud Ligny <arnaud@ligny.fr>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13

14
namespace Cecil\Util;
15

16
class Plateform
17
{
18
    public const OS_UNKNOWN = 1;
19
    public const OS_WIN = 2;
20
    public const OS_LINUX = 3;
21
    public const OS_OSX = 4;
22

23
    /** @var string */
24
    protected static $pharPath;
25

26
    /**
27
     * Running from Phar or not?
28
     */
29
    public static function isPhar(): bool
30
    {
31
        if (!empty(\Phar::running())) {
1✔
32
            self::$pharPath = \Phar::running();
×
33

34
            return true;
×
35
        }
36

37
        return false;
1✔
38
    }
39

40
    /**
41
     * Returns the full path on disk to the currently executing Phar archive.
42
     */
43
    public static function getPharPath(): string
44
    {
45
        if (!isset(self::$pharPath)) {
×
46
            if (!self::isPhar()) {
×
47
                throw new \Exception('Can\'t get Phar path.');
×
48
            }
49
        }
50

51
        return self::$pharPath;
×
52
    }
53

54
    /**
55
     * Whether the host machine is running a Windows OS.
56
     */
57
    public static function isWindows(): bool
58
    {
59
        return \defined('PHP_WINDOWS_VERSION_BUILD');
×
60
    }
61

62
    /**
63
     * Opens a URL in the system default browser.
64
     */
65
    public static function openBrowser(string $url): void
66
    {
67
        if (self::isWindows()) {
×
68
            passthru('start "web" explorer "' . $url . '"');
×
69

70
            return;
×
71
        }
72
        passthru('which xdg-open', $linux);
×
73
        passthru('which open', $osx);
×
74
        if (0 === $linux) {
×
75
            passthru('xdg-open ' . $url);
×
76
        } elseif (0 === $osx) {
×
77
            passthru('open ' . $url);
×
78
        }
79
    }
80

81
    /**
82
     * Search for system OS in PHP_OS constant.
83
     */
84
    public static function getOS(): int
85
    {
86
        switch (PHP_OS) {
87
            case 'Unix':
×
88
            case 'FreeBSD':
×
89
            case 'NetBSD':
×
90
            case 'OpenBSD':
×
91
            case 'Linux':
×
92
                return self::OS_LINUX;
×
93
            case 'WINNT':
×
94
            case 'WIN32':
×
95
            case 'Windows':
×
96
            case 'CYGWIN_NT':
×
97
                return self::OS_WIN;
×
98
            case 'Darwin':
×
99
                return self::OS_OSX;
×
100
            default:
101
                return self::OS_UNKNOWN;
×
102
        }
103
    }
104
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc