/** * @see \phpbu\App\Backup\Check::pass() * @param \phpbu\App\Backup\Target $target * @param string $value * @param \phpbu\App\Backup\Collector $collector * @param \phpbu\App\Result $result * @return boolean * @throws \phpbu\App\Exception */ public function pass(Target $target, $value, Collector $collector, Result $result) { // throws App\Exception if file doesn't exist $actualSize = $target->getSize(); $testSize = Str::toBytes($value); return $testSize <= $actualSize; }
/** * Setup the the Cleaner. * * @see \phpbu\App\Backup\Cleanup::setup() * @param array $options * @throws \phpbu\App\Backup\Cleaner\Exception */ public function setup(array $options) { if (!isset($options['size'])) { throw new Exception('option \'size\' is missing'); } try { $bytes = Str::toBytes($options['size']); } catch (RuntimeException $e) { throw new Exception($e->getMessage()); } $this->deleteTarget = isset($options['deleteTarget']) ? Str::toBoolean($options['deleteTarget'], false) : false; $this->capacityRaw = $options['size']; $this->capacityBytes = $bytes; }