Skip to content

Commit

Permalink
Update SRF_Math.php
Browse files Browse the repository at this point in the history
  • Loading branch information
paladox authored Feb 20, 2025
1 parent 0361fa5 commit 54851df
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions formats/math/SRF_Math.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

use SMW\DataValueFactory;
use SMW\Query\QueryResult;
use SMW\Query\ResultPrinters\ResultPrinter;

/**
* Various mathematical functions - sum, product, average, min, max, median, variance, samplevariance, samplestandarddeviation, standarddeviation, range, quartillower, quartilupper, quartillower.exc, quartilupper.exc, interquartilerange, interquartilerange.exc, mode and interquartilemean
*
Expand Down Expand Up @@ -236,11 +240,11 @@ public static function interquartilemean_function( array $numbers ) {
}
}

class SRFMath extends SMWResultPrinter {
class SRFMath extends ResultPrinter {

/**
* (non-PHPdoc)
* @see SMWResultPrinter::getName()
* @see ResultPrinter::getName()
*/
public function getName() {
// Give grep a chance to find the usages:
Expand All @@ -250,15 +254,15 @@ public function getName() {
}

/**
* @see SMWResultPrinter::buildResult
* @see ResultPrinter::buildResult
*
* @since 1.8
*
* @param SMWQueryResult $results
* @param QueryResult $results
*
* @return string
*/
protected function buildResult( SMWQueryResult $results ) {
protected function buildResult( QueryResult $results ) {
$number = $this->getResultText( $results, SMW_OUTPUT_HTML );

if ( count( $results->getPrintRequests() ) > 1 ) {
Expand All @@ -270,17 +274,17 @@ protected function buildResult( SMWQueryResult $results ) {

// if raw-format ("-") than skip formatNum()
if ( $outputformat != "-" ) {
$dataValue = \SMW\DataValueFactory::getInstance()->newDataValueByType( '_num' );
$dataValue = DataValueFactory::getInstance()->newDataValueByType( '_num' );
$number = $dataValue->getLocalizedFormattedNumber( $number );
}

return (string)$number;
}

/**
* @see SMWResultPrinter::getResultText()
* @see ResultPrinter::getResultText()
*/
protected function getResultText( SMWQueryResult $res, $outputmode ) {
protected function getResultText( QueryResult $res, $outputmode ) {
$numbers = $this->getNumbers( $res );

if ( count( $numbers ) == 0 ) {
Expand Down Expand Up @@ -330,11 +334,11 @@ protected function getResultText( SMWQueryResult $res, $outputmode ) {
}

/**
* @param SMWQueryResult $res
* @param QueryResult $res
*
* @return float[]
*/
private function getNumbers( SMWQueryResult $res ) {
private function getNumbers( QueryResult $res ) {
$numbers = [];

while ( $row = $res->getNext() ) {
Expand Down

0 comments on commit 54851df

Please sign in to comment.