Passed
Pull Request — master (#9)
by Shinji
03:42
created

CommandLineEnumerator::getIterator()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 2
nc 2
nop 0
dl 0
loc 8
c 1
b 0
f 1
cc 2
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\Process\ProcFileSystem;
15
16
use IteratorAggregate;
17
18
final class CommandLineEnumerator implements IteratorAggregate
19
{
20
    /**
21
     * @return \Generator<int, string>
22
     */
23
    public function getIterator()
24
    {
25
        /**
26
         * @var string $full_path
27
         * @var \SplFileInfo $item
28
         */
29
        foreach (new \GlobIterator('/proc/*/cmdline') as $full_path => $item) {
30
            yield (int)basename($item->getPath()) => file_get_contents($full_path);
31
        }
32
    }
33
}
34