diff --git a/LICENSE b/LICENSE index 34fa059..7054263 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ New BSD License =============== -Copyright (c) 2013, Soflomo +Copyright (c) 2013-2014, Soflomo All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/Module.php b/Module.php index 7316d23..f3c1ee3 100644 --- a/Module.php +++ b/Module.php @@ -1,6 +1,6 @@ - * @copyright 2013 Soflomo. + * @copyright 2013-2014 Soflomo. * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @link http://soflomo.com */ diff --git a/config/module.config.php b/config/module.config.php index 3e26b4b..2f47f48 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -6,7 +6,7 @@ 'routes' => array( 'cache-status' => array( 'options' => array( - 'route' => 'cache --status []', + 'route' => 'cache --status [] [-h]', 'defaults' => array( 'controller' => 'Soflomo\Cache\Controller\CacheController', 'action' => 'status' diff --git a/src/Soflomo/Cache/Controller/CacheController.php b/src/Soflomo/Cache/Controller/CacheController.php index d4272af..3847d0a 100644 --- a/src/Soflomo/Cache/Controller/CacheController.php +++ b/src/Soflomo/Cache/Controller/CacheController.php @@ -1,6 +1,6 @@ - * @copyright 2013 Soflomo. + * @copyright 2013-2014 Soflomo. * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @link http://soflomo.com */ @@ -61,23 +61,13 @@ public function statusAction() if ($cache instanceof TotalSpaceCapableInterface) { $space = $cache->getTotalSpace(); - $unit = 'B'; - if ($space > 1024) { - $space = $space/1024; - $unit = 'KB'; - } - if ($space > 1024) { - $space = $space/1024; - $unit = 'MB'; - } - if ($space > 1024) { - $space = $space/1024; - $unit = 'GB'; + if ($this->params('h')) { + $space = $this->convertToHumanSpace($space); } $console->writeLine(sprintf( - '%d%s total space', $space, $unit + '%s total space', $space )); } else { $console->writeLine('Cache adapter does not provide information about the total space of this cache'); @@ -85,30 +75,36 @@ public function statusAction() if ($cache instanceof AvailableSpaceCapableInterface) { $space = $cache->getAvailableSpace(); - $unit = 'B'; - if ($space > 1024) { - $space = $space/1024; - $unit = 'KB'; - } - if ($space > 1024) { - $space = $space/1024; - $unit = 'MB'; - } - if ($space > 1024) { - $space = $space/1024; - $unit = 'GB'; + if ($this->params('h')) { + $space = $this->convertToHumanSpace($space); } $console->writeLine(sprintf( - '%d%s available', $space, $unit + '%s available', $space )); } else { $console->writeLine('Cache adapter does not provide information about the available space of this cache'); } + } + + protected function convertToHumanSpace($space) + { + $unit = 'B'; + if ($space > 1024) { + $space = $space/1024; + $unit = 'KB'; + } + if ($space > 1024) { + $space = $space/1024; + $unit = 'MB'; + } + if ($space > 1024) { + $space = $space/1024; + $unit = 'GB'; + } - // Create empty line - $console->writeLine(''); + return sprintf('%d%s', $space, $unit); } public function clearAction()