Passed
Push — master ( ae2184...f6bfbf )
by Shinji
11:27 queued 09:50
created

EchoBackCanceller   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 17
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A __destruct() 0 6 2
1
<?php
2
3
/**
4
 * This file is part of the sj-i/php-profiler package.
5
 *
6
 * (c) sji <[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
12
declare(strict_types=1);
13
14
namespace PhpProfiler\Lib\Console;
15
16
final class EchoBackCanceller
17
{
18
    private ?string $stty_settings;
19
20
    public function __construct()
21
    {
22
        /** @psalm-suppress ForbiddenCode */
23
        $this->stty_settings = shell_exec('stty -g');
24
        exec('stty -icanon -echo');
25
    }
26
27
    public function __destruct()
28
    {
29
        if (isset($this->stty_settings)) {
30
            exec('stty ' . $this->stty_settings);
31
        } else {
32
            exec('stty icanon echo');
33
        }
34
    }
35
}
36