diff --git a/modules/statistics/bin/loganalyzer.php b/modules/statistics/bin/loganalyzer.php index 85ae093f3e31ab1dfdde61a1ce1ca304c4f17154..81e3d698a13114d12706d41086b83df988cc8d12 100755 --- a/modules/statistics/bin/loganalyzer.php +++ b/modules/statistics/bin/loganalyzer.php @@ -70,8 +70,8 @@ foreach ($results as $slot => $val) { /** * This function prints the help output. + * @return void */ - function printHelp() { global $progName; diff --git a/modules/statistics/bin/logcleaner.php b/modules/statistics/bin/logcleaner.php index b160cdab2780d2806831aa044a0e2655e1812bed..18432cf3852050d251fa8ba061bb6b611f2cd997 100755 --- a/modules/statistics/bin/logcleaner.php +++ b/modules/statistics/bin/logcleaner.php @@ -70,8 +70,8 @@ if (!$dryrun) { /** * This function prints the help output. + * @return void */ - function printHelp() { global $progName; diff --git a/modules/statistics/hooks/hook_configpage.php b/modules/statistics/hooks/hook_configpage.php index d9c1f1df7898b6b90d8c3f9cf6a869a47c63ff72..36853ed2d1f986e979fced5601c7f01c9c2eada3 100644 --- a/modules/statistics/hooks/hook_configpage.php +++ b/modules/statistics/hooks/hook_configpage.php @@ -1,8 +1,10 @@ <?php + /** * Hook to add the statistics module to the config page. * * @param \SimpleSAML\XHTML\Template &$template The template that we should alter in this hook. + * @return void */ function statistics_hook_configpage(\SimpleSAML\XHTML\Template &$template) { diff --git a/modules/statistics/hooks/hook_cron.php b/modules/statistics/hooks/hook_cron.php index a3ee4952cc347d567d4d044f4bbd83b05b7a7b5d..f0de516faf163b78c5e35004807c743ebc5705aa 100644 --- a/modules/statistics/hooks/hook_cron.php +++ b/modules/statistics/hooks/hook_cron.php @@ -4,8 +4,8 @@ * Hook to run a cron job. * * @param array &$croninfo Output + * @return void */ - function statistics_hook_cron(&$croninfo) { assert(is_array($croninfo)); diff --git a/modules/statistics/hooks/hook_frontpage.php b/modules/statistics/hooks/hook_frontpage.php index 2dade3b2af4c7e9cbf5422819fa44ac18a9d580a..bb4e934179a781a213bd886286916190f09b0d6d 100644 --- a/modules/statistics/hooks/hook_frontpage.php +++ b/modules/statistics/hooks/hook_frontpage.php @@ -1,8 +1,10 @@ <?php + /** * Hook to add the modinfo module to the frontpage. * * @param array &$links The links on the frontpage, split into sections. + * @return void */ function statistics_hook_frontpage(&$links) { diff --git a/modules/statistics/hooks/hook_sanitycheck.php b/modules/statistics/hooks/hook_sanitycheck.php index 879ee3ee784c292f68cd979d66420799b6251085..7d9fa22167eb5a96e6bc5c645681960a0ed89055 100644 --- a/modules/statistics/hooks/hook_sanitycheck.php +++ b/modules/statistics/hooks/hook_sanitycheck.php @@ -1,8 +1,10 @@ <?php + /** * Hook to do sanity checks * * @param array &$hookinfo hookinfo + * @return void */ function statistics_hook_sanitycheck(&$hookinfo) { diff --git a/modules/statistics/lib/AccessCheck.php b/modules/statistics/lib/AccessCheck.php index 750a5d0526e0aa3aa494e6f0ffdba9dc70dbef6c..8750714415e647f8e7550c21e3e6ae1c477c06e8 100644 --- a/modules/statistics/lib/AccessCheck.php +++ b/modules/statistics/lib/AccessCheck.php @@ -7,13 +7,16 @@ namespace SimpleSAML\Module\statistics; * * @package SimpleSAMLphp */ - class AccessCheck { /** * Check that the user has access to the statistics. - * * If the user doesn't have access, send the user to the login page. + * + * @param \SimpleSAML\Configuration $statconfig + * @return void + * @throws \Exception + * @throws \SimpleSAML\Error\Exception */ public static function checkAccess(\SimpleSAML\Configuration $statconfig) { diff --git a/modules/statistics/lib/Aggregator.php b/modules/statistics/lib/Aggregator.php index 966012d6399329c6b5f250a3d68e53b9f22197e8..dc311d4d4d4c8eb66365261f9a62d5577f298050 100644 --- a/modules/statistics/lib/Aggregator.php +++ b/modules/statistics/lib/Aggregator.php @@ -6,21 +6,40 @@ namespace SimpleSAML\Module\statistics; * @author Andreas Ă…kre Solberg <andreas.solberg@uninett.no> * @package SimpleSAMLphp */ - class Aggregator { + /** @var \SimpleSAML\Configuration */ private $statconfig; + + /** @var string */ private $statdir; + + /** @var string */ private $inputfile; + + /** @var array */ private $statrules; + + /** @var int */ private $offset; - private $metadata; + + /** @var array|null */ + private $metadata = null; + + /** @var bool */ private $fromcmdline; + + /** @var int */ private $starttime; + + /** @var array */ private $timeres; + /** * Constructor + * + * @param bool $fromcmdline */ public function __construct($fromcmdline = false) { @@ -32,11 +51,14 @@ class Aggregator $this->statrules = $this->statconfig->getValue('statrules'); $this->timeres = $this->statconfig->getValue('timeres'); $this->offset = $this->statconfig->getValue('offset', 0); - $this->metadata = null; $this->starttime = time(); } + + /** + * @return void + */ public function dumpConfig() { echo 'Statistics directory : '.$this->statdir."\n"; @@ -44,11 +66,19 @@ class Aggregator echo 'Offset : '.$this->offset."\n"; } + + /** + * @return void + */ public function debugInfo() { echo 'Memory usage : '.number_format(memory_get_usage() / 1048576, 2)." MB\n"; // 1024*1024=1048576 } + + /** + * @return void + */ public function loadMetadata() { $filename = $this->statdir.'/.stat.metadata'; @@ -59,11 +89,19 @@ class Aggregator $this->metadata = $metadata; } + + /** + * @return array|null + */ public function getMetadata() { return $this->metadata; } + + /** + * @return void + */ public function saveMetadata() { $this->metadata['time'] = time() - $this->starttime; @@ -74,6 +112,12 @@ class Aggregator file_put_contents($filename, serialize($this->metadata), LOCK_EX); } + + /** + * @param bool $debug + * @return array + * @throws \Exception + */ public function aggregate($debug = false) { $this->loadMetadata(); @@ -210,6 +254,12 @@ class Aggregator return $results; } + + /** + * @param array $content + * @param mixed $colrule + * @return string + */ private static function getDifCol($content, $colrule) { if (is_int($colrule)) { @@ -225,6 +275,12 @@ class Aggregator } } + + /** + * @param mixed $previous + * @param array $newdata + * @return array + */ private function cummulateData($previous, $newdata) { $dataset = []; @@ -244,6 +300,11 @@ class Aggregator return $dataset; } + + /** + * @param array $results + * @return void + */ public function store($results) { $datehandler = [ diff --git a/modules/statistics/lib/DateHandler.php b/modules/statistics/lib/DateHandler.php index ae9807df9ea6907992b4e25c7aad2921df49fcd2..17534e2d688b476d9b3592e969334523f38b46c0 100644 --- a/modules/statistics/lib/DateHandler.php +++ b/modules/statistics/lib/DateHandler.php @@ -2,25 +2,30 @@ namespace SimpleSAML\Module\statistics; -/* +/** * @author Andreas Ă…kre Solberg <andreas.solberg@uninett.no> * @package SimpleSAMLphp */ - class DateHandler { + /** @var int */ protected $offset; /** * Constructor * - * @param array $offset Date offset + * @param int $offset Date offset */ public function __construct($offset) { $this->offset = $offset; } + + /** + * @param int $timestamp + * @return int + */ protected function getDST($timestamp) { if (idate('I', $timestamp)) { @@ -29,12 +34,24 @@ class DateHandler return 0; } + + /** + * @param int $epoch + * @param int $slotsize + * @return float + */ public function toSlot($epoch, $slotsize) { $dst = $this->getDST($epoch); return floor(($epoch + $this->offset + $dst) / $slotsize); } + + /** + * @param int $slot + * @param int $slotsize + * @return int + */ public function fromSlot($slot, $slotsize) { $temp = $slot * $slotsize - $this->offset; @@ -42,16 +59,37 @@ class DateHandler return $slot * $slotsize - $this->offset - $dst; } + + /** + * @param int $epoch + * @param string $dateformat + * @return string + */ public function prettyDateEpoch($epoch, $dateformat) { return date($dateformat, $epoch); } + + /** + * @param int $slot + * @param int $slotsize + * @param string $dateformat + * @return string + */ public function prettyDateSlot($slot, $slotsize, $dateformat) { return $this->prettyDateEpoch($this->fromSlot($slot, $slotsize), $dateformat); } + + /** + * @param int $from + * @param int $to + * @param int $slotsize + * @param string $dateformat + * @return string + */ public function prettyHeader($from, $to, $slotsize, $dateformat) { $text = $this->prettyDateSlot($from, $slotsize, $dateformat); diff --git a/modules/statistics/lib/DateHandlerMonth.php b/modules/statistics/lib/DateHandlerMonth.php index 058795f57b05beb2964ef43fcda96edbac1c81c7..4404c44e14396e2d14429f7b27a516efda4b64c4 100644 --- a/modules/statistics/lib/DateHandlerMonth.php +++ b/modules/statistics/lib/DateHandlerMonth.php @@ -6,7 +6,6 @@ namespace SimpleSAML\Module\statistics; * @author Andreas Ă…kre Solberg <andreas.solberg@uninett.no> * @package SimpleSAMLphp */ - class DateHandlerMonth extends DateHandler { /** @@ -19,6 +18,12 @@ class DateHandlerMonth extends DateHandler $this->offset = $offset; } + + /** + * @param int $epoch + * @param int $slotsize + * @return int + */ public function toSlot($epoch, $slotsize) { $dsttime = $this->getDST($epoch) + $epoch; @@ -27,6 +32,12 @@ class DateHandlerMonth extends DateHandler return $slot; } + + /** + * @param int $slot + * @param int $slotsize + * @return int + */ public function fromSlot($slot, $slotsize) { $month = ($slot % 12); @@ -34,6 +45,14 @@ class DateHandlerMonth extends DateHandler return mktime(0, 0, 0, $month + 1, 1, $year); } + + /** + * @param int $from + * @param int $to + * @param int $slotsize + * @param string $dateformat + * @return string + */ public function prettyHeader($from, $to, $slotsize, $dateformat) { $month = ($from % 12) + 1; diff --git a/modules/statistics/lib/Graph/GoogleCharts.php b/modules/statistics/lib/Graph/GoogleCharts.php index 129639de50d103e4002b0504e7e3c3a117242141..22f4e9993039cbc0de09b2dbd4632a82564d1f3b 100644 --- a/modules/statistics/lib/Graph/GoogleCharts.php +++ b/modules/statistics/lib/Graph/GoogleCharts.php @@ -9,7 +9,6 @@ namespace SimpleSAML\Module\statistics\Graph; * @author Andreas Ă…kre Solberg <andreas.solberg@uninett.no> * @package SimpleSAMLphp */ - class GoogleCharts { /** @@ -36,12 +35,21 @@ class GoogleCharts $this->y = $y; } + + /** + * @param array $axis + * @return string + */ private function encodeaxis($axis) { return join('|', $axis); } - // t:10.0,58.0,95.0 + /** + * t:10.0,58.0,95.0 + * @param array $datasets + * @return string + */ private function encodedata($datasets) { $setstr = []; @@ -51,6 +59,11 @@ class GoogleCharts return 'e:'.join(',', $setstr); } + + /** + * @param array $values + * @return string + */ public static function extEncode($values) // $max = 4095, $min = 0 { $extended_table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.'; @@ -70,15 +83,17 @@ class GoogleCharts return $chardata; } + /** * Generate a Google Charts URL which points to a generated image. * More documentation on Google Charts here: * http://code.google.com/apis/chart/ * - * @param string $axis Axis - * @param string $axpis Axis positions + * @param array $axis Axis + * @param array $axispos Axis positions * @param array $datasets Datasets values - * @param integer $max Max value. Will be the topmost value on the Y-axis. + * @param array $maxes Max value. Will be the topmost value on the Y-axis. + * @return string */ public function show($axis, $axispos, $datasets, $maxes) { @@ -111,6 +126,12 @@ class GoogleCharts return $url; } + + /** + * @param array $axis + * @param array $datasets + * @return string + */ public function showPie($axis, $datasets) { $url = 'https://chart.apis.google.com/chart?'. @@ -129,6 +150,7 @@ class GoogleCharts return $url; } + /** * Takes a input value, and generates a value that suits better as a max * value on the Y-axis. In example 37.6 will not make a good max value, instead @@ -145,7 +167,8 @@ class GoogleCharts * } * </code> * - * @param integer $max Input value. + * @param int $max Input value. + * @return int */ public static function roof($max) { diff --git a/modules/statistics/lib/LogCleaner.php b/modules/statistics/lib/LogCleaner.php index eafb501904e36d7cac8883a3edb1b70da4bca12f..ee20e18bf457c8d5a37b2caa110cb8192d5b5cb5 100644 --- a/modules/statistics/lib/LogCleaner.php +++ b/modules/statistics/lib/LogCleaner.php @@ -2,21 +2,32 @@ namespace SimpleSAML\Module\statistics; -/* +/** * @author Andreas Ă…kre Solberg <andreas.solberg@uninett.no> * @package SimpleSAMLphp */ - class LogCleaner { + /** @var \SimpleSAML\Configuration */ private $statconfig; + + /** @var string */ private $statdir; + + /** @var string */ private $inputfile; + + /** @var array */ private $statrules; + + /** @var int */ private $offset; + /** * Constructor + * + * @param string|null $inputfile */ public function __construct($inputfile = null) { @@ -32,7 +43,8 @@ class LogCleaner } } - /* + + /** * @return void */ public function dumpConfig() @@ -43,9 +55,10 @@ class LogCleaner } - /* + /** * @param bool $debug * @return array + * @throws \Exception */ public function clean($debug = false) { @@ -125,10 +138,11 @@ class LogCleaner } - /* + /** * @param array $todelete * @param string $outputfile * @return void + * @throws \Exceeption */ public function store($todelete, $outputfile) { diff --git a/modules/statistics/lib/RatioDataset.php b/modules/statistics/lib/RatioDataset.php index 5449a3fd1797c03c08b9d04d8e530f58d8202be4..eaed4652402b2cdd884943847cbc37527d09c1a1 100644 --- a/modules/statistics/lib/RatioDataset.php +++ b/modules/statistics/lib/RatioDataset.php @@ -2,13 +2,15 @@ namespace SimpleSAML\Module\statistics; -/* +/** * @author Andreas Ă…kre Solberg <andreas.solberg@uninett.no> * @package SimpleSAMLphp */ - class RatioDataset extends StatDataset { + /** + * @return void + */ public function aggregateSummary() { /** @@ -42,6 +44,12 @@ class RatioDataset extends StatDataset $this->summary = array_reverse($this->summary, true); } + + /** + * @param string $k + * @param array $a + * @return int + */ private function ag($k, $a) { if (array_key_exists($k, $a)) { @@ -50,6 +58,12 @@ class RatioDataset extends StatDataset return 0; } + + /** + * @param int $v1 + * @param int $v2 + * @return int|float + */ private function divide($v1, $v2) { if ($v2 == 0) { @@ -58,6 +72,12 @@ class RatioDataset extends StatDataset return ($v1 / $v2); } + + /** + * @param array $result1 + * @param array $result2 + * @return array + */ public function combine($result1, $result2) { $combined = []; @@ -74,6 +94,10 @@ class RatioDataset extends StatDataset return $combined; } + + /** + * @return null + */ public function getPieData() { return null; diff --git a/modules/statistics/lib/Ruleset.php b/modules/statistics/lib/Ruleset.php index 935bad407daf2c4d75b1b7b5350c28557b74afda..f0a41a70c977116f7f1c479b8005901883b18ab1 100644 --- a/modules/statistics/lib/Ruleset.php +++ b/modules/statistics/lib/Ruleset.php @@ -6,16 +6,25 @@ namespace SimpleSAML\Module\statistics; * @author Andreas Ă…kre Solberg <andreas.solberg@uninett.no> * @package SimpleSAMLphp */ - class Ruleset { + /** \SimpleSAML\Configuration */ private $statconfig; + + /** @var array */ private $availrulenames; + + /** @var array */ private $availrules; + + /** @var array */ private $available; + /** * Constructor + * + * @param \SimpleSAML\Configuration $statconfig */ public function __construct($statconfig) { @@ -23,6 +32,10 @@ class Ruleset $this->init(); } + + /** + * @return void + */ private function init() { $statdir = $this->statconfig->getValue('statdir'); @@ -61,18 +74,30 @@ class Ruleset $this->availrulenames = $available_rules; } + + /** + * @return array + */ public function availableRules() { return $this->availrules; } + + /** + * @return array + */ public function availableRulesNames() { return $this->availrulenames; } + /** * Resolve which rule is selected. Taking user preference and checks if it exists. + * + * @param array|null $preferRule + * @return array|null */ private function resolveSelectedRule($preferRule = null) { @@ -85,6 +110,11 @@ class Ruleset return $rule; } + + /** + * @param array|null $preferRule + * @return \SimpleSAML\Module\statistics\Statistics\Rulesets\BaseRule + */ public function getRule($preferRule) { $rule = $this->resolveSelectedRule($preferRule); diff --git a/modules/statistics/lib/StatDataset.php b/modules/statistics/lib/StatDataset.php index 6868d023775dd2126b2532a83434403d9a6bf4c1..5183f12db4b19d3c1a192a992b6edaba835cd326 100644 --- a/modules/statistics/lib/StatDataset.php +++ b/modules/statistics/lib/StatDataset.php @@ -6,28 +6,53 @@ namespace SimpleSAML\Module\statistics; * @author Andreas Ă…kre Solberg <andreas.solberg@uninett.no> * @package SimpleSAMLphp */ - class StatDataset { + /** @var \SimpleSAML\Configuration */ protected $statconfig; + + /** @var \SimpleSAML\Configuration */ protected $ruleconfig; + + /** @var \SimpleSAML\Configuration */ protected $timeresconfig; + + /** @var string */ protected $ruleid; + /** @var int */ protected $fileslot; + + /** @var string */ protected $timeres; + /** @var string */ protected $delimiter; + + /** @var array */ protected $results; + + /** @var array */ protected $summary; + + /** @var int */ protected $max; + /** @var \SimpleSAML\Module\statistics\DateHandler */ protected $datehandlerFile; + + /** @var \SimpleSAML\Module\statistics\DateHandler */ protected $datehandlerTick; /** * Constructor + * + * @param \SimpleSAML\Configuration $statconfig + * @param \SimpleSAML\Configuration $ruleconfig + * @param string $ruleid + * @param string $timeres + * @param int $fileslot */ public function __construct($statconfig, $ruleconfig, $ruleid, $timeres, $fileslot) { @@ -56,16 +81,29 @@ class StatDataset $this->loadData(); } + + /** + * @return int + */ public function getFileSlot() { return $this->fileslot; } + + /** + * @return string + */ public function getTimeRes() { return $this->timeres; } + + /** + * @param string $delimiter + * @return void + */ public function setDelimiter($delimiter = '_') { if (empty($delimiter)) { @@ -74,6 +112,10 @@ class StatDataset $this->delimiter = $delimiter; } + + /** + * @return string|null + */ public function getDelimiter() { if ($this->delimiter === '_') { @@ -82,6 +124,10 @@ class StatDataset return $this->delimiter; } + + /** + * @return void + */ public function calculateMax() { $maxvalue = 0; @@ -94,6 +140,10 @@ class StatDataset $this->max = Graph\GoogleCharts::roof($maxvalue); } + + /** + * @return array + */ public function getDebugData() { $debugdata = []; @@ -110,6 +160,10 @@ class StatDataset return $debugdata; } + + /** + * @return void + */ public function aggregateSummary() { // aggregate summary table from dataset. To be used in the table view @@ -127,6 +181,10 @@ class StatDataset $this->summary = array_reverse($this->summary, true); } + + /** + * @return array + */ public function getTopDelimiters() { // create a list of delimiter keys that has the highest total summary in this period @@ -144,6 +202,10 @@ class StatDataset return $topdelimiters; } + + /** + * @return array + */ public function availDelimiters() { $availDelimiters = []; @@ -153,6 +215,10 @@ class StatDataset return array_keys($availDelimiters); } + + /** + * @return array + */ public function getPieData() { $piedata = []; @@ -167,21 +233,37 @@ class StatDataset return $piedata; } + + /** + * @return int + */ public function getMax() { return $this->max; } + + /** + * @return array + */ public function getSummary() { return $this->summary; } + + /** + * @return array + */ public function getResults() { return $this->results; } + + /** + * @return array + */ public function getAxis() { $slotsize = $this->timeresconfig->getValue('slot'); @@ -209,8 +291,10 @@ class StatDataset return ['axis' => $axis, 'axispos' => $axispos]; } - /* + + /** * Walk through dataset to get percent values from max into dataset[]. + * @return array */ public function getPercentValues() { @@ -232,6 +316,11 @@ class StatDataset return $dataset; } + + /** + * @return array + * @throws \Exception + */ public function getDelimiterPresentation() { $config = \SimpleSAML\Configuration::getInstance(); @@ -257,6 +346,10 @@ class StatDataset return []; } + + /** + * @return array + */ public function getDelimiterPresentationPie() { $topdelimiters = $this->getTopDelimiters(); @@ -274,6 +367,10 @@ class StatDataset return $pieaxis; } + + /** + * @return void + */ public function loadData() { $statdir = $this->statconfig->getValue('statdir'); diff --git a/modules/statistics/lib/Statistics/FieldPresentation/Base.php b/modules/statistics/lib/Statistics/FieldPresentation/Base.php index bb2568f1d6c8814acf4da00021d22ab7fb0ed8cb..8f0bd99c0086446922df494cace9df608e0151ca 100644 --- a/modules/statistics/lib/Statistics/FieldPresentation/Base.php +++ b/modules/statistics/lib/Statistics/FieldPresentation/Base.php @@ -4,10 +4,21 @@ namespace SimpleSAML\Module\statistics\Statistics\FieldPresentation; class Base { + /** @var array */ protected $fields; + + /** @var \SimpleSAML\XHTML\Template */ protected $template; + + /** @var string */ protected $config; + + /** + * @param array $fields + * @param string $config + * @param \SimpleSAML\XHTML\Template $template + */ public function __construct($fields, $config, $template) { $this->fields = $fields; @@ -15,6 +26,10 @@ class Base $this->config = $config; } + + /** + * @return array + */ public function getPresentation() { return ['_' => 'Total']; diff --git a/modules/statistics/lib/Statistics/FieldPresentation/Entity.php b/modules/statistics/lib/Statistics/FieldPresentation/Entity.php index 624d215b7936cf16c4ce7fa5327742e08c71557a..df88c8e4f710e6d97958cd2c41a2f5e71d99bdab 100644 --- a/modules/statistics/lib/Statistics/FieldPresentation/Entity.php +++ b/modules/statistics/lib/Statistics/FieldPresentation/Entity.php @@ -4,6 +4,9 @@ namespace SimpleSAML\Module\statistics\Statistics\FieldPresentation; class Entity extends Base { + /** + * @return array + */ public function getPresentation() { $mh = \SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler(); diff --git a/modules/statistics/lib/Statistics/Rulesets/BaseRule.php b/modules/statistics/lib/Statistics/Rulesets/BaseRule.php index 875557bc8dab7c8a0896fe196208d9d57abf1e5b..77c3a20513b1bdff5eeb3c70732b2a165e25b4a8 100644 --- a/modules/statistics/lib/Statistics/Rulesets/BaseRule.php +++ b/modules/statistics/lib/Statistics/Rulesets/BaseRule.php @@ -6,16 +6,27 @@ namespace SimpleSAML\Module\statistics\Statistics\Rulesets; * @author Andreas Ă…kre Solberg <andreas.solberg@uninett.no> * @package SimpleSAMLphp */ - class BaseRule { + /** @var \SimpleSAML\Configuration */ protected $statconfig; + + /** @var \SimpleSAML\Configuration */ protected $ruleconfig; + + /** @var string */ protected $ruleid; - protected $available; + + /** @var array|null */ + protected $available = null; /** * Constructor + * + * @param \SimpleSAML\Configuration $statconfig + * @param \SimpleSAML\Configuration $ruleconfig + * @param string $ruleid + * @param array $available */ public function __construct($statconfig, $ruleconfig, $ruleid, $available) { @@ -25,17 +36,24 @@ class BaseRule $this->ruleconfig = $ruleconfig; $this->ruleid = $ruleid; - $this->available = null; if (array_key_exists($ruleid, $available)) { $this->available = $available[$ruleid]; } } + + /** + * @return string + */ public function getRuleID() { return $this->ruleid; } + + /** + * @return array + */ public function availableTimeRes() { $timeresConfigs = $this->statconfig->getValue('timeres'); @@ -48,6 +66,11 @@ class BaseRule return $available_times; } + + /** + * @param string $timeres + * @return array + */ public function availableFileSlots($timeres) { $timeresConfigs = $this->statconfig->getValue('timeres'); @@ -74,6 +97,11 @@ class BaseRule return $available_times; } + + /** + * @param string $preferTimeRes + * @return string + */ protected function resolveTimeRes($preferTimeRes) { $timeresavailable = array_keys($this->available); @@ -86,6 +114,12 @@ class BaseRule return $timeres; } + + /** + * @param string $timeres + * @param string $preferTime + * @return int + */ protected function resolveFileSlot($timeres, $preferTime) { // Get which time (fileslot) to use.. First get a default, which is the most recent one. @@ -97,6 +131,12 @@ class BaseRule return $fileslot; } + + /** + * @param string $timeres + * @param string $preferTime + * @return array + */ public function getTimeNavigation($timeres, $preferTime) { $fileslot = $this->resolveFileSlot($timeres, $preferTime); @@ -118,6 +158,12 @@ class BaseRule return ['prev' => $available_times_prev, 'next' => $available_times_next]; } + + /** + * @param string $preferTimeRes + * @param string $preferTime + * @return \SimpleSAML\Module\statistics\StatDataset + */ public function getDataSet($preferTimeRes, $preferTime) { $timeres = $this->resolveTimeRes($preferTimeRes); diff --git a/modules/statistics/lib/Statistics/Rulesets/Ratio.php b/modules/statistics/lib/Statistics/Rulesets/Ratio.php index 1f76f6b4709791447db69970aafcf7d666e02175..ed3a6eb9936ae85fa5e72fbc1a92ef7f8474fda2 100644 --- a/modules/statistics/lib/Statistics/Rulesets/Ratio.php +++ b/modules/statistics/lib/Statistics/Rulesets/Ratio.php @@ -6,14 +6,22 @@ namespace SimpleSAML\Module\statistics\Statistics\Rulesets; * @author Andreas Ă…kre Solberg <andreas.solberg@uninett.no> * @package SimpleSAMLphp */ - class Ratio extends BaseRule { + /** @var \SimpleSAML\Module\statistics\Statistics\Rulesets\BaseRule $refrule1 */ protected $refrule1; + + /** @var \SimpleSAML\Module\statistics\Statistics\Rulesets\BaseRule $refrule2 */ protected $refrule2; + /** * Constructor + * + * @param \SimpleSAML\Configuration $statconfig + * @param \SimpleSAML\Configuration $ruleconfig + * @param string $ruleid + * @param array $available */ public function __construct($statconfig, $ruleconfig, $ruleid, $available) { @@ -33,31 +41,63 @@ class Ratio extends BaseRule $this->refrule2 = new BaseRule($this->statconfig, $statruleConfig2, $refNames[1], $available); } + + /** + * @return array + */ public function availableTimeRes() { return $this->refrule1->availableTimeRes(); } + + /** + * @param string $timeres + * @return array + */ public function availableFileSlots($timeres) { return $this->refrule1->availableFileSlots($timeres); } + + /** + * @param string $preferTimeRes + * @return string + */ protected function resolveTimeRes($preferTimeRes) { return $this->refrule1->resolveTimeRes($preferTimeRes); } + + /** + * @param string $timeres + * @param string $preferTime + * @return int + */ protected function resolveFileSlot($timeres, $preferTime) { return $this->refrule1->resolveFileSlot($timeres, $preferTime); } + + /** + * @param string $timeres + * @param string $preferTime + * @return array + */ public function getTimeNavigation($timeres, $preferTime) { return $this->refrule1->getTimeNavigation($timeres, $preferTime); } + + /** + * @param string $preferTimeRes + * @param string $preferTime + * @return \SimpleSAML\Module\statistics\RatioDataset + */ public function getDataSet($preferTimeRes, $preferTime) { $timeres = $this->resolveTimeRes($preferTimeRes); diff --git a/modules/statistics/lib/StatisticsController.php b/modules/statistics/lib/StatisticsController.php index 2da8806a74faeb4c47325ac7e31ebbe473960489..5110307931100cd267eaef95f91fb1163459a42f 100644 --- a/modules/statistics/lib/StatisticsController.php +++ b/modules/statistics/lib/StatisticsController.php @@ -203,6 +203,14 @@ class StatisticsController return $t; } + + /** + * @param \SimpleSAML\XHTML\Template $t + * @param string $type + * @param string|null $key + * @param string|null $value + * @return string|array + */ private function getBaseURL($t, $type = 'get', $key = null, $value = null) { $vars = [ diff --git a/modules/statistics/www/showstats.php b/modules/statistics/www/showstats.php index 7011126ea54ccd23085772ace12510fb5f47a6c1..544a9c4f7a851a15b223db6fa099bc5446e0418d 100644 --- a/modules/statistics/www/showstats.php +++ b/modules/statistics/www/showstats.php @@ -151,6 +151,14 @@ $t->data['jquery'] = ['core' => false, 'ui' => true, 'css' => true]; $t->show(); + +/** + * @param \SimpleSAML\XHTML\Template $t + * @param string $type + * @param string|null $key + * @param string|null $value + * @return string|array + */ function getBaseURL($t, $type = 'get', $key = null, $value = null) { $vars = [