ProgressBarRenderer::getProgressHtml()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * File: ProgressBarRenderer.php
7
 *
8
 * @author Maciej Sławik <[email protected]>
9
 * @copyright Copyright (C) 2019 Lizard Media (http://lizardmedia.pl)
10
 */
11
12
namespace LizardMedia\VarnishWarmer\Model\ProgressHandler;
13
14
use LizardMedia\VarnishWarmer\Api\ProgressHandler\ProgressBarRendererInterface;
15
use LizardMedia\VarnishWarmer\Api\ProgressHandler\ProgressDataInterface;
16
17
/**
18
 * Class ProgressBarRenderer
19
 * @package LizardMedia\VarnishWarmer\Model\ProgressHandler
20
 */
21
class ProgressBarRenderer implements ProgressBarRendererInterface
22
{
23
    /**
24
     * @param ProgressDataInterface $progressData
25
     * @return string
26
     */
27
    public function getProgressHtml(ProgressDataInterface $progressData): string
28
    {
29
        return $progressData->getCurrent()
30
            ? "{$progressData->getProcessType()} progress: "
31
                . "<progress max=\"{$progressData->getTotal()}\" value=\"{$progressData->getCurrent()}\"></progress> "
32
                . "({$progressData->getCurrent()}/{$progressData->getTotal()})"
33
            : '';
34
    }
35
}
36