From 985b603cf3996b3362c01c7aec1eb1aa53c0197b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Thu, 21 Jan 2016 15:20:52 +0100 Subject: [PATCH] Remove unused argument on databox::dispatch method --- lib/classes/databox.php | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/lib/classes/databox.php b/lib/classes/databox.php index 198035ec56..582a129674 100644 --- a/lib/classes/databox.php +++ b/lib/classes/databox.php @@ -230,24 +230,21 @@ class databox extends base implements ThumbnailedElement return $databox; } - public static function dispatch(Filesystem $filesystem, $repository_path, $date = false) + public static function dispatch(Filesystem $filesystem, $repository_path) { - if (! $date) { - $date = date('Y-m-d H:i:s'); - } - $repository_path = p4string::addEndSlash($repository_path); - $year = date('Y', strtotime($date)); - $month = date('m', strtotime($date)); - $day = date('d', strtotime($date)); + $timestamp = strtotime(date('Y-m-d')); + $year = date('Y', $timestamp); + $month = date('m', $timestamp); + $day = date('d', $timestamp); - $n = 0; $comp = $year . DIRECTORY_SEPARATOR . $month . DIRECTORY_SEPARATOR . $day . DIRECTORY_SEPARATOR; - while (($pathout = $repository_path . $comp . self::addZeros($n)) && is_dir($pathout) && iterator_count(new \DirectoryIterator($pathout)) > 100) { - $n ++; - } + $n = 0; + do { + $pathout = sprintf('%s%s%05d', $repository_path, $comp, $n++); + } while (is_dir($pathout) && iterator_count(new DirectoryIterator($pathout)) > 100); $filesystem->mkdir($pathout, 0750); @@ -337,10 +334,6 @@ class databox extends base implements ThumbnailedElement self::$_xpath_thesaurus = self::$_dom_thesaurus = self::$_thesaurus = self::$_sxml_thesaurus = []; } - private static function addZeros($n, $length = 5) - { - return str_pad($n, $length, '0'); - } /** @var int */ protected $id; /** @var string */