Assert\Assertion::eq PHP Method

eq() public static method

Assert that two values are equal (using == ).
public static eq ( mixed $value, mixed $value2, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$value2 mixed
$message string | null
$propertyPath string | null
return boolean
    public static function eq($value, $value2, $message = null, $propertyPath = null)
    {
        if ($value != $value2) {
            $message = sprintf($message ?: 'Value "%s" does not equal expected value "%s".', static::stringify($value), static::stringify($value2));
            throw static::createException($value, $message, static::INVALID_EQ, $propertyPath, array('expected' => $value2));
        }
        return true;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @param \Jose\Object\JWSInterface $jws
  * @param array                     $data
  */
 private static function populatePayload(JWSInterface &$jws, array $data)
 {
     $is_encoded = null;
     foreach ($jws->getSignatures() as $signature) {
         if (null === $is_encoded) {
             $is_encoded = self::isPayloadEncoded($signature);
         }
         Assertion::eq($is_encoded, self::isPayloadEncoded($signature), 'Foreign payload encoding detected. The JWS cannot be loaded.');
     }
     if (array_key_exists('payload', $data)) {
         $payload = $data['payload'];
         $jws = $jws->withAttachedPayload();
         $jws = $jws->withEncodedPayload($payload);
         if (false !== $is_encoded) {
             $payload = Base64Url::decode($payload);
         }
         $json = json_decode($payload, true);
         if (null !== $json && !empty($payload)) {
             $payload = $json;
         }
         $jws = $jws->withPayload($payload);
     } else {
         $jws = $jws->withDetachedPayload();
     }
 }
All Usage Examples Of Assert\Assertion::eq