DjThossi/smoke-testing-php

View on GitHub
src/ValueObject/Body.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php
namespace DjThossi\SmokeTestingPhp\ValueObject;

use DjThossi\Ensure\EnsureIsStringTrait;

class Body
{
    use EnsureIsStringTrait;

    const BODY_IS_NOT_A_STRING = 1;

    /**
     * @var string
     */
    private $body;

    /**
     * @param string $body
     */
    public function __construct($body)
    {
        $this->ensureBody($body);

        $this->body = $body;
    }

    /**
     * @return string
     */
    public function asString()
    {
        return $this->body;
    }

    /**
     * @param mixed $body
     */
    private function ensureBody($body)
    {
        $this->ensureIsString('Body', $body, self::BODY_IS_NOT_A_STRING);
    }
}