*/ class State { public const STATUS_DONE = 'done'; public const STATUS_PROGRESS = 'progress'; public const STATUS_DEFAULT = 'unknown'; public const KEY_FILENAME = 'filename'; public const KEY_INDEX = 'index'; public const KEY_STATE = 'state'; public const KEY_FILES_COUNTER = 'files_counter'; /** * @var Registry */ private $registry; public function __construct(Registry $registry) { $this->registry = $registry; } /** * Get the Index. */ public function index(): int { return (int) $this->stateProperty(self::KEY_INDEX, -1); } /** * Get File Name. */ public function fileName(): string { return (string) $this->stateProperty(self::KEY_FILENAME, ''); } /** * Get the State. */ public function state(): string { return (string) $this->stateProperty(self::KEY_STATE, ''); } // TODO Introduce Files Counter. /** * Retrieve the Property Decompression State or default value. * * @param string|int $default * * @return string|int */ private function stateProperty(string $property, $default) // phpcs:ignore { $state = $this->registry->decompression_state; return $state[$property] ?? $default; } }