Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
4 / 4
StringExpectation
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
2 / 2
3
100.00% covered (success)
100.00%
4 / 4
 getType
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 expect
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
3 / 3
<?php
/**
 * Copyright (c) Tony Bogdanov <tonybogdanov@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace DataExpectation;
use DataExpectation\Exceptions\UnexpectedDataException;
/**
 * Class StringExpectation
 *
 * @package DataExpectation
 * @author Tony Bogdanov <tonybogdanov@gmail.com>
 */
class StringExpectation extends AbstractExpectation {
    /**
     * @return string
     */
    public function getType(): string {
        return 'string';
    }
    /**
     * @param $data
     * @param string|null $path
     *
     * @return $this
     * @throws UnexpectedDataException
     */
    public function expect( $data, string $path = null ) {
        if ( ! is_string( $data ) ) {
            throw new UnexpectedDataException( $data, $this, $path );
        }
        return $this;
    }
}