soliantconsulting/SimpleFM

View on GitHub
src/Repository/Builder/Type/StreamType.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php
declare(strict_types = 1);

namespace Soliant\SimpleFM\Repository\Builder\Type;

use Assert\Assertion;
use Psr\Http\Message\StreamInterface;
use Soliant\SimpleFM\Repository\Builder\Type\Exception\DomainException;

final class StreamType implements TypeInterface
{
    public function fromFileMakerValue($value)
    {
        if (null === $value) {
            return null;
        }

        Assertion::isInstanceOf($value, StreamInterface::class);
        return $value;
    }

    public function toFileMakerValue($value)
    {
        throw DomainException::fromAttemptedStreamConversionToFileMakerValue();
    }
}