Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 39 and 400]

(no description)

File Size: 290 lines (10 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: CellValueFormatter  - X-Ref

Class CellValueFormatter
This class provides helper functions to format cell values

__construct($shouldFormatDates, $escaper)   X-Ref

param: bool $shouldFormatDates Whether date/time values should be returned as PHP objects or be formatted as strings
param: \Box\Spout\Common\Helper\Escaper\ODS $escaper Used to unescape XML data

extractAndFormatNodeValue($node)   X-Ref
Returns the (unescaped) correctly marshalled, cell value associated to the given XML node.

return: string|int|float|bool|\DateTime|\DateInterval The value associated with the cell, empty string if cell's type is void/undefined
param: \DOMNode $node

formatStringCellValue($node)   X-Ref
Returns the cell String value.

return: string The value associated with the cell
param: \DOMNode $node

extractTextValueFromNode($pNode)   X-Ref

return: string
param: $pNode

isWhitespaceNode($nodeName)   X-Ref
Returns whether the given node is a whitespace node. It must be one of these:
- <text:s />
- <text:tab />
- <text:line-break />

return: bool
param: string $nodeName

transformWhitespaceNode($node)   X-Ref
The "<text:p>" node can contain the string value directly
or contain child elements. In this case, whitespaces contain in
the child elements should be replaced by their XML equivalent:
- space => <text:s />
- tab => <text:tab />
- line break => <text:line-break />

return: string The corresponding whitespace value
param: \DOMNode $node The XML node representing a whitespace

formatFloatCellValue($node)   X-Ref
Returns the cell Numeric value from the given node.

return: int|float The value associated with the cell
param: \DOMNode $node

formatBooleanCellValue($node)   X-Ref
Returns the cell Boolean value from the given node.

return: bool The value associated with the cell
param: \DOMNode $node

formatDateCellValue($node)   X-Ref
Returns the cell Date value from the given node.

return: \DateTime|string The value associated with the cell
param: \DOMNode $node

formatTimeCellValue($node)   X-Ref
Returns the cell Time value from the given node.

return: \DateInterval|string The value associated with the cell
param: \DOMNode $node

formatCurrencyCellValue($node)   X-Ref
Returns the cell Currency value from the given node.

return: string The value associated with the cell (e.g. "100 USD" or "9.99 EUR")
param: \DOMNode $node

formatPercentageCellValue($node)   X-Ref
Returns the cell Percentage value from the given node.

return: int|float The value associated with the cell
param: \DOMNode $node