romanpitak/dotMailer-API-v2-PHP-client

View on GitHub
src/DataTypes/XsInt.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php
/**
 *
 *
 * @author Roman Piták <roman@pitak.net>
 *
 */


namespace DotMailer\Api\DataTypes;


final class XsInt implements IDataType
{

    private $value;

    public function __construct($value)
    {
        if (is_int($value) || (((string)(int)$value) == $value)) {
            $this->value = $value;
        } else {
            throw new InvalidValueException();
        }
    }

    public function toJson()
    {
        return (string)$this->value;
    }

    public function __toString()
    {
        return (string)$this->toJson();
    }

    public function toArray()
    {
        return $this->toJson();
    }

}