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

EchoBackCanceller::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
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