private function getDfColumn($line, $columnName)
    {
        $columnPatterns = [
            'filesystem' => '#^(.+?)(\s+[0-9])#',
            'total' => '#([0-9]+)\s+[0-9]+\s+[0-9]+\s+[0-9]+%\s+#',
            'used' => '#([0-9]+)\s+[0-9]+\s+[0-9]+%\s+#',
            'available' => '#([0-9]+)\s+[0-9]+%\s+#',
            'path' => '#%\s+(/.+)$#',
        ];
        if (!isset($columnPatterns[$columnName])) {
            throw new \InvalidArgumentException("Invalid df column: $columnName");
        }
        if (!preg_match($columnPatterns[$columnName], $line, $matches)) {
            throw new \RuntimeException("Failed to find column '$columnName' in df line: \n$line");
        }

        return trim($matches[1]);
    }
private function getDfColumn($line, $columnName)
    {
        $columnPatterns = [
            'filesystem' => '#^(.+?)(\s+[0-9])#',
            'total' => '#([0-9]+)\s+[0-9]+\s+[0-9]+\s+[0-9]+%\s+#',
            'used' => '#([0-9]+)\s+[0-9]+\s+[0-9]+%\s+#',
            'available' => '#([0-9]+)\s+[0-9]+%\s+#',
            'path' => '#%\s+(/.+)$#',
        ];
        if (!isset($columnPatterns[$columnName])) {
            throw new \InvalidArgumentException("Invalid df column: $columnName");
        }
        if (!preg_match($columnPatterns[$columnName], $line, $matches)) {
            throw new \RuntimeException("Failed to find column '$columnName' in df line: \n$line");
        }

        return trim($matches[1]);
    }
private function getDfColumn ( $ line , $ columnName ) { $ columnPatterns = [ 'filesystem' => '#^(.+?)(\s+[0-9])#' , 'total' => '#([0-9]+)\s+[0-9]+\s+[0-9]+\s+[0-9]+%\s+#' , 'used' => '#([0-9]+)\s+[0-9]+\s+[0-9]+%\s+#' , 'available' => '#([0-9]+)\s+[0-9]+%\s+#' , 'path' => '#%\s+(/.+)$#' , ] ; if ( ! isset ( $ columnPatterns [ $ columnName ] ) ) { throw new \ InvalidArgumentException ( "Invalid df column: $columnName" ) ; } if ( ! preg_match ( $ columnPatterns [ $ columnName ] , $ line , $ matches ) ) { throw new \ RuntimeException ( "Failed to find column '$columnName' in df line: \n$line" ) ; } return trim ( $ matches [ 1 ] ) ; }
Get a column from a line of df output.

Unfortunately there doesn't seem to be a more reliable way to parse df
output than by regular expression.

@param string $line
@param string $columnName

@return string
Get a column from a line of df output .