Definition at line 34 of file EstimatedReadingTime.php.
◆ __construct()
ILIAS\Refinery\String\EstimatedReadingTime::__construct |
( |
bool |
$withImages | ) |
|
◆ addErrors()
ILIAS\Refinery\String\EstimatedReadingTime::addErrors |
( |
| ) |
|
|
private |
Definition at line 147 of file EstimatedReadingTime.php.
147 : void
148 {
149 $currentErrors = libxml_get_errors();
150 libxml_clear_errors();
151
152 $this->xmlErrors = $currentErrors;
153 }
◆ beginXmlLogging()
ILIAS\Refinery\String\EstimatedReadingTime::beginXmlLogging |
( |
| ) |
|
|
private |
Definition at line 141 of file EstimatedReadingTime.php.
141 : void
142 {
143 $this->xmlErrorState = libxml_use_internal_errors(true);
144 libxml_clear_errors();
145 }
◆ calculateWordsForImages()
ILIAS\Refinery\String\EstimatedReadingTime::calculateWordsForImages |
( |
int |
$numberOfImages | ) |
|
|
private |
- See also
- https://blog.medium.com/read-time-and-you-bc2048ab620c
- Parameters
-
- Returns
- float The calculated reading time for the passed number of images translated to words
Definition at line 126 of file EstimatedReadingTime.php.
126 : float
127 {
128 $time = 0.0;
129
130 for ($i = 1; $i <= $numberOfImages; $i++) {
131 if ($i >= 10) {
132 $time += 3 * ($this->wordsPerMinute / 60);
133 } else {
134 $time += (12 - ($i - 1)) * ($this->wordsPerMinute / 60);
135 }
136 }
137
138 return $time;
139 }
◆ endXmlLogging()
ILIAS\Refinery\String\EstimatedReadingTime::endXmlLogging |
( |
| ) |
|
|
private |
◆ transform()
ILIAS\Refinery\String\EstimatedReadingTime::transform |
( |
|
$from | ) |
|
@inheritDoc
Implements ILIAS\Refinery\Transformation.
Definition at line 53 of file EstimatedReadingTime.php.
53 : int
54 {
55 if (!is_string($from)) {
56 throw new InvalidArgumentException(__METHOD__ . ' the argument is not a string.');
57 }
58
59 return $this->calculate($from);
60 }
◆ xmlErrorsOccurred()
ILIAS\Refinery\String\EstimatedReadingTime::xmlErrorsOccurred |
( |
| ) |
|
|
private |
◆ xmlErrorsToString()
ILIAS\Refinery\String\EstimatedReadingTime::xmlErrorsToString |
( |
| ) |
|
|
private |
Definition at line 165 of file EstimatedReadingTime.php.
165 : string
166 {
167 $text = '';
168 foreach ($this->xmlErrors as
$error) {
169 $text .= implode(',', [
174 'msg=' . trim(
$error->message)
175 ]) . "\n";
176 }
177
178 return $text;
179 }
References ILIAS\$error.
◆ $withImages
bool ILIAS\Refinery\String\EstimatedReadingTime::$withImages |
|
private |
◆ $wordsPerMinute
int ILIAS\Refinery\String\EstimatedReadingTime::$wordsPerMinute = 275 |
|
private |
◆ $xmlErrors
array ILIAS\Refinery\String\EstimatedReadingTime::$xmlErrors = [] |
|
private |
◆ $xmlErrorState
bool ILIAS\Refinery\String\EstimatedReadingTime::$xmlErrorState = false |
|
private |
The documentation for this class was generated from the following file: