SelfTestCliOsChecks   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 38
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A doTest() 0 9 2
A checkDarwin() 0 15 2
1
<?php
2
3
/**
4
 * This file is part of tenside/core.
5
 *
6
 * (c) Christian Schiffler <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * This project is provided in good faith and hope to be usable by anyone.
12
 *
13
 * @package    tenside/core
14
 * @author     Christian Schiffler <[email protected]>
15
 * @copyright  2015 Christian Schiffler <[email protected]>
16
 * @license    https://github.com/tenside/core/blob/master/LICENSE MIT
17
 * @link       https://github.com/tenside/core
18
 * @filesource
19
 */
20
21
namespace Tenside\Core\SelfTest\Cli;
22
23
use Tenside\Core\SelfTest\AbstractSelfTest;
24
25
/**
26
 * This class tests for any OS specific hacks that shall get enabled.
27
 */
28
class SelfTestCliOsChecks extends AbstractSelfTest
29
{
30
    /**
31
     * Perform all checks.
32
     *
33
     * @return void
34
     */
35
    public function doTest()
36
    {
37
        $this->setMessage('Check if any OS specific workaround should be enabled.');
38
39
        $flagged = $this->checkDarwin();
40
        if (!$flagged) {
41
            $this->markSuccess('Good, no hacks in place');
42
        }
43
    }
44
45
    /**
46
     * Check if any Darwin specific hacks must get enabled.
47
     *
48
     * @return bool True if modified, false otherwise.
49
     */
50
    private function checkDarwin()
51
    {
52
        if ('Darwin' !== PHP_OS) {
53
            return false;
54
        }
55
56
        // Apply hack to force process into background as it keeps sticky on Darwin.
57
        // Dunno why but as I lack the hardware and knowledge of said OS, this hack will have to do.
58
        $this->getAutoConfig()->setForceToBackground(true);
59
        $this->markSuccess(
60
            'Mac OS X (Darwin) detected, force-to-background-workaround enabled.'
61
        );
62
63
        return true;
64
    }
65
}
66