kodekeep/cereal

View on GitHub
src/Value.php

Summary

Maintainability
A
3 hrs
Test Coverage
F
0%
<?php

declare(strict_types=1);

/*
 * This file is part of Cereal.
 *
 * (c) KodeKeep <hello@kodekeep.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace KodeKeep\Cereal;

use KodeKeep\Cereal\Normalisers\ValueNormaliser;

class Value
{
    protected $normaliser;

    public function __construct()
    {
        $this->normaliser = new ValueNormaliser();
    }

    public function serialise($input): string
    {
        return $this->normaliser->serialiser()->serialise($input);
    }

    public function unserialise($input, ?string $class = null): array
    {
        return $this->normaliser->unserialiser()->unserialise($input, $class);
    }

    public function write($path, $input): bool
    {
        return $this->normaliser->writer()->write($path, $input);
    }

    public function read($input, ?string $class = null): array
    {
        return $this->normaliser->reader()->read($path, $class);
    }
}