src/SysInfo/Linux/Disk.php
private function sumField($devices = null, $partitions = null, $field) {
        $result = 0;

        if ($devices) {
            $devices = (array) $devices;
        }

        if (is_array($devices)) {
            $devices = array_flip($devices);
        }

        if ($partitions) {
            $partitions = (array) $partitions;
        }

        if (is_array($partitions)) {
            $partitions = array_flip($partitions);
        }

        foreach ($this->devices as $device => $partition) {
            if ($devices && !isset($devices[$device])) {
                continue;
            }

            foreach ($partition as $p => $info) {
                if ($partitions && !isset($partitions[$p])) {
                    continue;
                }

                $result += $info[$field];
            }
        }

        return $result;
    }
private function sumField($devices = null, $partitions = null, $field) {
        $result = 0;

        if ($devices) {
            $devices = (array) $devices;
        }

        if (is_array($devices)) {
            $devices = array_flip($devices);
        }

        if ($partitions) {
            $partitions = (array) $partitions;
        }

        if (is_array($partitions)) {
            $partitions = array_flip($partitions);
        }

        foreach ($this->devices as $device => $partition) {
            if ($devices && !isset($devices[$device])) {
                continue;
            }

            foreach ($partition as $p => $info) {
                if ($partitions && !isset($partitions[$p])) {
                    continue;
                }

                $result += $info[$field];
            }
        }

        return $result;
    }
private function sumField ( $ devices = null , $ partitions = null , $ field ) { $ result = 0 ; if ( $ devices ) { $ devices = ( array ) $ devices ; } if ( is_array ( $ devices ) ) { $ devices = array_flip ( $ devices ) ; } if ( $ partitions ) { $ partitions = ( array ) $ partitions ; } if ( is_array ( $ partitions ) ) { $ partitions = array_flip ( $ partitions ) ; } foreach ( $ this -> devices as $ device => $ partition ) { if ( $ devices && ! isset ( $ devices [ $ device ] ) ) { continue ; } foreach ( $ partition as $ p => $ info ) { if ( $ partitions && ! isset ( $ partitions [ $ p ] ) ) { continue ; } $ result += $ info [ $ field ] ; } } return $ result ; }
Calcuate a sum

@param string|string[] $devices The name of the device to fetch, for instance "sda", or an
array of device names: array('hda', 'hdb').
@param int|int[] $partitions Which partition(s) to fetch info about.
@return int
Calcuate a sum