| Conditions | 5 |
| Paths | 4 |
| Total Lines | 30 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | public function collect(): array |
||
| 14 | { |
||
| 15 | $passwdFile = self::PASSWORD_FILE; |
||
| 16 | |||
| 17 | if (!file_exists($passwdFile) || !is_readable($passwdFile)) { |
||
| 18 | return []; |
||
| 19 | } |
||
| 20 | |||
| 21 | $users = []; |
||
| 22 | |||
| 23 | foreach (file($passwdFile) as $line) { |
||
| 24 | $parts = explode(':', trim($line)); |
||
| 25 | |||
| 26 | if (count($parts) < 7) { |
||
| 27 | continue; |
||
| 28 | } |
||
| 29 | |||
| 30 | list($username, $password, $uid, $gid, $comment, $home, $shell) = $parts; |
||
| 31 | |||
| 32 | $users[] = [ |
||
| 33 | 'username' => $username, |
||
| 34 | 'uid' => (int)$uid, |
||
| 35 | 'gid' => (int)$gid, |
||
| 36 | 'comment' => $comment, |
||
| 37 | 'home' => $home, |
||
| 38 | 'shell' => $shell, |
||
| 39 | ]; |
||
| 40 | } |
||
| 41 | |||
| 42 | return ['users' => $users]; |
||
| 43 | } |
||
| 46 |