Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
8 / 8
DataTraveller
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
3 / 3
4
100.00% covered (success)
100.00%
8 / 8
 get
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
5 / 5
 isDisableRegexSteps
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setDisableRegexSteps
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
<?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 DataTraveller;
use DataExpectation\Exceptions\UnexpectedDataException;
use DataExpectation\ExpectationInterface;
use DataTraveller\Exceptions\MissingDataException;
use DataTraveller\Path\Exceptions\InvalidPathException;
use DataTraveller\Path\Path;
/**
 * Class DataTraveller
 *
 * @package DataTraveller
 * @author Tony Bogdanov <tonybogdanov@gmail.com>
 */
class DataTraveller {
    /**
     * @var bool
     */
    protected $disableRegexSteps = false;
    /**
     * @param string $path
     * @param $data
     * @param ExpectationInterface $expectation
     *
     * @return mixed
     * @throws InvalidPathException
     * @throws MissingDataException
     * @throws UnexpectedDataException
     */
    public function get( string $path, $data, ExpectationInterface $expectation = null ) {
        $path = Path::parse( $path, $this->isDisableRegexSteps() );
        $value = $path->get( $data );
        if ( isset( $expectation ) ) {
            $expectation->expect( $value, $path );
            
        }
        return $value;
    }
    /**
     * @return bool
     */
    public function isDisableRegexSteps(): bool {
        return $this->disableRegexSteps;
    }
    /**
     * @param bool $disableRegexSteps
     *
     * @return $this
     */
    public function setDisableRegexSteps( bool $disableRegexSteps ) {
        $this->disableRegexSteps = $disableRegexSteps;
        return $this;
    }
}