smartemailing/types

View on GitHub
src/ExtractableTraits/IntExtractableTrait.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

declare(strict_types = 1);

namespace SmartEmailing\Types\ExtractableTraits;

use SmartEmailing\Types\IntType;

trait IntExtractableTrait
{

    use ExtractableTrait;

    abstract public function __construct(
        int $value
    );

    /**
     * @param string|mixed|array<mixed> $data
     * @return static
     */
    final public static function from(
        $data
    ) {
        if ($data instanceof self) {
            return $data;
        }

        $data = IntType::from($data);

        return new static($data);
    }

}