oliverde8 /
phpEtlBundle
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Oliverde8\PhpEtlBundle\Twig; |
||
| 4 | |||
| 5 | use Twig\Extension\AbstractExtension; |
||
|
0 ignored issues
–
show
|
|||
| 6 | use Twig\TwigFilter; |
||
|
0 ignored issues
–
show
The type
Twig\TwigFilter was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 7 | |||
| 8 | class TimeIntervalExtension extends AbstractExtension |
||
| 9 | { |
||
| 10 | public function getFilters() |
||
| 11 | { |
||
| 12 | return [ |
||
| 13 | new TwigFilter('timeSpent', [$this, 'formatTime']), |
||
| 14 | ]; |
||
| 15 | } |
||
| 16 | |||
| 17 | public function formatTime($time) |
||
| 18 | { |
||
| 19 | |||
| 20 | $time = abs($time); |
||
| 21 | $sec = str_pad($time % 60, 2, '0', STR_PAD_LEFT); |
||
| 22 | $min = str_pad(floor($time / 60), 2, '0', STR_PAD_LEFT); |
||
| 23 | $hour = str_pad(floor($time / 60 / 60), 1, '0'); |
||
| 24 | |||
| 25 | $formattedPieces = []; |
||
| 26 | if ($time > (60*60)) { |
||
| 27 | $formattedPieces[] = $hour . "h"; |
||
| 28 | } |
||
| 29 | if ($time > (60)) { |
||
| 30 | $formattedPieces[] = $min . "m"; |
||
| 31 | } |
||
| 32 | $formattedPieces[] = $sec . "s"; |
||
| 33 | |||
| 34 | return implode(" ", $formattedPieces); |
||
| 35 | } |
||
| 36 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths