keboola/juicer

View on GitHub
src/Pagination/AbstractScroller.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php

declare(strict_types=1);

namespace Keboola\Juicer\Pagination;

use Psr\Log\LoggerInterface;

abstract class AbstractScroller implements ScrollerInterface
{
    protected LoggerInterface $logger;

    public function __construct(LoggerInterface $logger)
    {
        $this->logger = $logger;
    }

    /**
     * Get object vars by default
     */
    public function getState(): array
    {
        return get_object_vars($this);
    }

    public function setState(array $state): void
    {
        foreach (array_keys(get_object_vars($this)) as $key) {
            if (isset($state[$key])) {
                $this->{$key} = $state[$key];
            }
        }
    }
}