src/Check/DiskSpaceCheck.php
private function checkDiskSpace()
    {
        $retValue = array();
        $freeSpace = disk_free_space($this->directory);
        $totalSpace = disk_total_space($this->directory);
        if (0 === $totalSpace) {
            $retValue[] = new CheckOutcome(
                'check.disk_space.totalzero',
                array('%0%' => $this->directory),
                CheckOutcome::ERROR
            );

            return $retValue;
        }
        $percentage = 100 * ($freeSpace / $totalSpace);

        $maxLevel = 0;
        $maxStrategy = self::STRATEGY_ABSOLUTE;

        foreach ($this->thresholdData as $level => $data) {
            $threshold = $data[0];
            $strategy = $data[1];

            switch ($strategy) {
                case self::STRATEGY_ABSOLUTE:
                    if (($freeSpace < $threshold) && $level > $maxLevel) {
                        $maxLevel = $level;
                        $maxStrategy = self::STRATEGY_ABSOLUTE;
                    }
                    break;
                case self::STRATEGY_PERCENTAGE:
                    if (($percentage < $threshold) && $level > $maxLevel) {
                        $maxLevel = $level;
                        $maxStrategy = self::STRATEGY_PERCENTAGE;
                    }
                    break;
                default:
                    $retValue[] = new CheckOutcome(
                        'check.disk_space.invalid_strategy',
                        array('%0%' => $strategy),
                        CheckOutcome::ERROR
                    );
                    break;
            }
        }

        if ($maxLevel > 0) {
            $retValue[] = new CheckOutcome(
                'check.disk_space.lowspace', array(
                '%0%' => $this->directory,
                '%1%' => $this->formatSpaceLeft($freeSpace, $totalSpace, $maxStrategy),
            ), $maxLevel
            );
        } else {
            $retValue[] = new CheckOutcome('check.disk_space.ok', array(), CheckOutcome::OK);
        }

        return $retValue;
    }
private function checkDiskSpace()
    {
        $retValue = array();
        $freeSpace = disk_free_space($this->directory);
        $totalSpace = disk_total_space($this->directory);
        if (0 === $totalSpace) {
            $retValue[] = new CheckOutcome(
                'check.disk_space.totalzero',
                array('%0%' => $this->directory),
                CheckOutcome::ERROR
            );

            return $retValue;
        }
        $percentage = 100 * ($freeSpace / $totalSpace);

        $maxLevel = 0;
        $maxStrategy = self::STRATEGY_ABSOLUTE;

        foreach ($this->thresholdData as $level => $data) {
            $threshold = $data[0];
            $strategy = $data[1];

            switch ($strategy) {
                case self::STRATEGY_ABSOLUTE:
                    if (($freeSpace < $threshold) && $level > $maxLevel) {
                        $maxLevel = $level;
                        $maxStrategy = self::STRATEGY_ABSOLUTE;
                    }
                    break;
                case self::STRATEGY_PERCENTAGE:
                    if (($percentage < $threshold) && $level > $maxLevel) {
                        $maxLevel = $level;
                        $maxStrategy = self::STRATEGY_PERCENTAGE;
                    }
                    break;
                default:
                    $retValue[] = new CheckOutcome(
                        'check.disk_space.invalid_strategy',
                        array('%0%' => $strategy),
                        CheckOutcome::ERROR
                    );
                    break;
            }
        }

        if ($maxLevel > 0) {
            $retValue[] = new CheckOutcome(
                'check.disk_space.lowspace', array(
                '%0%' => $this->directory,
                '%1%' => $this->formatSpaceLeft($freeSpace, $totalSpace, $maxStrategy),
            ), $maxLevel
            );
        } else {
            $retValue[] = new CheckOutcome('check.disk_space.ok', array(), CheckOutcome::OK);
        }

        return $retValue;
    }
private function checkDiskSpace ( ) { $ retValue = array ( ) ; $ freeSpace = disk_free_space ( $ this -> directory ) ; $ totalSpace = disk_total_space ( $ this -> directory ) ; if ( 0 === $ totalSpace ) { $ retValue [ ] = new CheckOutcome ( 'check.disk_space.totalzero' , array ( '%0%' => $ this -> directory ) , CheckOutcome :: ERROR ) ; return $ retValue ; } $ percentage = 100 * ( $ freeSpace / $ totalSpace ) ; $ maxLevel = 0 ; $ maxStrategy = self :: STRATEGY_ABSOLUTE ; foreach ( $ this -> thresholdData as $ level => $ data ) { $ threshold = $ data [ 0 ] ; $ strategy = $ data [ 1 ] ; switch ( $ strategy ) { case self :: STRATEGY_ABSOLUTE : if ( ( $ freeSpace < $ threshold ) && $ level > $ maxLevel ) { $ maxLevel = $ level ; $ maxStrategy = self :: STRATEGY_ABSOLUTE ; } break ; case self :: STRATEGY_PERCENTAGE : if ( ( $ percentage < $ threshold ) && $ level > $ maxLevel ) { $ maxLevel = $ level ; $ maxStrategy = self :: STRATEGY_PERCENTAGE ; } break ; default : $ retValue [ ] = new CheckOutcome ( 'check.disk_space.invalid_strategy' , array ( '%0%' => $ strategy ) , CheckOutcome :: ERROR ) ; break ; } } if ( $ maxLevel > 0 ) { $ retValue [ ] = new CheckOutcome ( 'check.disk_space.lowspace' , array ( '%0%' => $ this -> directory , '%1%' => $ this -> formatSpaceLeft ( $ freeSpace , $ totalSpace , $ maxStrategy ) , ) , $ maxLevel ) ; } else { $ retValue [ ] = new CheckOutcome ( 'check.disk_space.ok' , array ( ) , CheckOutcome :: OK ) ; } return $ retValue ; }
Checks the space left on the disk given by the configured directory.

@return array
Checks the space left on the disk given by the configured directory .