Mac   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getCoreCount() 0 5 1
A inUse() 0 3 1
1
<?php
2
/**
3
 * @package     Cronfig Sysinfo Library
4
 * @link        https://github.com/cronfig/sysinfo
5
 * @license     http://opensource.org/licenses/MIT
6
 */
7
8
namespace Cronfig\Sysinfo;
9
10
/**
11
 * Class Mac
12
 */
13
class Mac extends AbstractOs implements OsInterface
14
{
15
    /**
16
     * Checks whether the current OS is equal to the current class
17
     *
18
     * @return bool
19
     */
20
    public function inUse()
21
    {
22
        return strtolower($this->getCurrentOsName()) === 'darwin';
23
    }
24
25
    /**
26
     * Counts CPU cores of the current system
27
     *
28
     * @return int
29
     */
30
    public function getCoreCount()
31
    {
32
        $this->requiredFunction('shell_exec');
33
34
        return (int) trim(shell_exec('sysctl -n hw.ncpu'));
35
    }
36
}
37