for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types=1);
namespace AlecRabbit\Spinner\Core\Jugglers;
use AlecRabbit\Accessories\Circular;
use AlecRabbit\Spinner\Settings\Contracts\Defaults;
use function AlecRabbit\Helpers\bounds;
class ProgressJuggler extends AbstractJuggler
{
/** @var string */
protected $spacer = Defaults::ONE_SPACE_SYMBOL;
protected $currentFrame;
public function __construct(float $percent, Circular $style = null)
$this->style = $style ?? new Circular(['%s',]);
$this->update($percent);
}
/**
* @param float $percent
*/
protected function update(float $percent): void
$progress = bounds($percent, 0, 1);
$this->currentFrame = $this->prefix. (int)($progress * 100) . '%' . $this->suffix . $this->spacer;
$this->currentFrameErasingLength = strlen($this->currentFrame);
public function setProgress(float $percent): void
* @return string
protected function getCurrentFrame(): string
return $this->currentFrame;