コード例 #1
0
 /**
  * @test
  */
 public function canReplaceExistingRecognition()
 {
     Parse::addRecognition(function ($string) {
         if ('Binford 6100' === $string) {
             return true;
         }
     }, 'booleanTrue');
     assertTrue(Parse::toType('Binford 6100'));
 }
コード例 #2
0
ファイル: functions.php プロジェクト: stubbles/stubbles-peer
/**
 * Functions in namespace stubbles\peer\http.
 */
namespace stubbles\peer\http;

/**
 * returns an empty accept header representation
 *
 * @return  \stubbles\peer\http\AcceptHeader
 * @since   4.0.0
 * @api
 */
function emptyAcceptHeader() : AcceptHeader
{
    return new AcceptHeader();
}
if (class_exists('stubbles\\values\\Parse')) {
    \stubbles\values\Parse::addRecognition(function ($string) {
        if (substr($string, 0, 4) === Http::SCHEME) {
            try {
                return HttpUri::fromString($string);
            } catch (\stubbles\peer\MalformedUri $murle) {
            }
        }
        return;
    }, HttpUri::class);
}
if (class_exists('stubbles\\values\\Value')) {
    \stubbles\values\Value::defineCheck('isHttpUri', [HttpUri::class, 'isValid']);
    \stubbles\values\Value::defineCheck('isExistingHttpUri', [HttpUri::class, 'exists']);
}