|
| __construct (bool $withImages) |
| ReadingTime constructor. More...
|
|
| transform ($from) |
| Perform the transformation.Please use this for transformations. It's more performant than calling invoke.- Exceptions
-
InvalidArgumentException if the argument could not be transformed - Parameters
-
- Returns
- mixed
More...
|
|
| transform ($from) |
| Perform the transformation. More...
|
|
| applyTo (Result $data) |
| Perform the transformation and reify possible failures. More...
|
|
| __invoke ($from) |
| Transformations should be callable. More...
|
|
Definition at line 10 of file EstimatedReadingTime.php.
◆ __construct()
ILIAS\Refinery\String\EstimatedReadingTime::__construct |
( |
bool |
$withImages | ) |
|
◆ 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 98 of file EstimatedReadingTime.php.
98 : float
99 {
100 $time = 0.0;
101
102 for (
$i = 1;
$i <= $numberOfImages;
$i++) {
104 $time += 3 * ((int) $this->wordsPerMinute / 60);
105 } else {
106 $time += (12 - (
$i - 1)) * ((int) $this->wordsPerMinute / 60);
107 }
108 }
109
110 return $time;
111 }
References $i.
◆ transform()
ILIAS\Refinery\String\EstimatedReadingTime::transform |
( |
|
$from | ) |
|
Perform the transformation.Please use this for transformations. It's more performant than calling invoke.
- Exceptions
-
InvalidArgumentException if the argument could not be transformed
- Parameters
-
- Returns
- mixed
Implements ILIAS\Refinery\Transformation.
Definition at line 36 of file EstimatedReadingTime.php.
37 {
38 if (!is_string($from)) {
39 throw new \InvalidArgumentException(__METHOD__ . " the argument is not a string.");
40 }
41
42 return $this->calculate($from);
43 }
◆ $firstImageReadingTimeInSeconds
ILIAS\Refinery\String\EstimatedReadingTime::$firstImageReadingTimeInSeconds = 12 |
|
private |
◆ $withImages
ILIAS\Refinery\String\EstimatedReadingTime::$withImages = false |
|
private |
◆ $wordsPerMinute
ILIAS\Refinery\String\EstimatedReadingTime::$wordsPerMinute = 275 |
|
private |
The documentation for this class was generated from the following file: