• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JBZoo / Cli / 7685763438

28 Jan 2024 12:35PM UTC coverage: 80.746% (-3.1%) from 83.803%
7685763438

push

github

web-flow
Add support for PHP 8.3 and update Symfony dependencies to ^6.4 (#24)

* Add support for PHP 8.3 and update Symfony dependencies to ^6.4
* Fix default value handling in CliCommand

0 of 3 new or added lines in 1 file covered. (0.0%)

41 existing lines in 5 files now uncovered.

952 of 1179 relevant lines covered (80.75%)

234.54 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/ProgressBars/ProgressBarProcessManager.php
1
<?php
2

3
/**
4
 * JBZoo Toolbox - Cli.
5
 *
6
 * This file is part of the JBZoo Toolbox project.
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license    MIT
11
 * @copyright  Copyright (C) JBZoo.com, All rights reserved.
12
 * @see        https://github.com/JBZoo/Cli
13
 */
14

15
declare(strict_types=1);
16

17
namespace JBZoo\Cli\ProgressBars;
18

19
use JBZoo\Cli\CliRender;
20
use JBZoo\Cli\Icons;
21
use JBZoo\Cli\OutputMods\AbstractOutputMode;
22
use Symfony\Component\Console\Helper\ProgressBar as SymfonyProgressBar;
23
use Symfony\Component\Console\Output\OutputInterface;
24

25
class ProgressBarProcessManager extends AbstractSymfonyProgressBar
26
{
27
    private OutputInterface $output;
28

29
    private SymfonyProgressBar $progressBar;
30

31
    public function __construct(AbstractOutputMode $outputMode)
32
    {
33
        parent::__construct($outputMode);
×
34

35
        $this->output      = $outputMode->getOutput();
×
36
        $this->progressBar = $this->createProgressBar($this->output);
×
37
    }
38

39
    public function start(): void
40
    {
41
        $this->progressBar->start();
×
42
    }
43

44
    public function finish(): void
45
    {
46
        $this->progressBar->finish();
×
47
    }
48

49
    public function advance(): void
50
    {
51
        $this->progressBar->advance();
×
52
    }
53

54
    public function execute(): bool
55
    {
56
        return true;
×
57
    }
58

59
    protected function buildTemplate(): string
60
    {
61
        $this->configureProgressBar();
×
62
        $finishIcon = Icons::getRandomIcon(Icons::GROUP_FINISH, $this->output->isDecorated());
×
63

64
        $progressBarLines = [
×
UNCOV
65
            '%percent:2s%%',
×
UNCOV
66
            '(%current% / %max%)',
×
UNCOV
67
            '[%bar%]',
×
UNCOV
68
            $finishIcon,
×
UNCOV
69
            '%jbzoo_memory_current:8s%',
×
UNCOV
70
        ];
×
71

72
        $footerLine = [
×
73
            'Time (pass/left/est)' => \implode(' / ', [
×
UNCOV
74
                '%jbzoo_time_elapsed:8s%',
×
UNCOV
75
                '<info>%jbzoo_time_remaining:8s%</info>',
×
UNCOV
76
                '%jbzoo_time_estimated%',
×
UNCOV
77
            ]),
×
78

UNCOV
79
            'Caught exceptions' => '%jbzoo_caught_exceptions%',
×
UNCOV
80
        ];
×
81

82
        return \implode(' ', $progressBarLines) . "\n" . CliRender::list($footerLine) . "\n";
×
83
    }
84

85
    private function createProgressBar(OutputInterface $output, int $maxCount = 0): SymfonyProgressBar
86
    {
87
        $progressBar = new SymfonyProgressBar($output, $maxCount);
×
88

89
        $progressBar->setBarCharacter('<green>•</green>');
×
90
        $progressBar->setEmptyBarCharacter('<yellow>_</yellow>');
×
91
        $progressBar->setProgressCharacter(Icons::getRandomIcon(Icons::GROUP_PROGRESS, $this->output->isDecorated()));
×
92
        $progressBar->setBarWidth(40);
×
93
        $progressBar->setFormat($this->buildTemplate());
×
94

95
        $progressBar->setMessage('n/a');
×
96
        $progressBar->setMessage('0', 'jbzoo_caught_exceptions');
×
97
        $progressBar->setProgress(0);
×
98
        $progressBar->setOverwrite(true);
×
99

100
        $progressBar->setRedrawFrequency(1);
×
101
        $progressBar->minSecondsBetweenRedraws(0.5);
×
102
        $progressBar->maxSecondsBetweenRedraws(1.5);
×
103

104
        return $progressBar;
×
105
    }
106
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc