Invalid Argument exception factory

@param string $expected
@param mixed $actual
@param null|integer $paramNo
@param null|integer $code
@param null|\Exception $previous
@return InvalidArgumentException A new instance of self
487937
public static function create(
        $expected,
        $actual,
        $paramNo = null,
        $code = null,
        $previous = null
    ) {
        $msgMsk = 'Expected %1$s. Got %2$s';

        if ($paramNo !== null) {
            $msgMsk = 'Param #%3$s '.lcfirst($msgMsk);
        }

        if ($code !== null) {
            $msgMsk = '[%4$s] '.$msgMsk;
        }

        $class = get_called_class();
        return new $class(
            sprintf(
                $msgMsk,
                $expected,
                Debug::summarise($actual),
                $paramNo,
                $code
            ),
            is_int($code) ? $code : null,
            $previous
        );
    }
409159
protected function _createStringTranslationException($message, $code = 0, \Exception $previous = null, $subject = null, TranslatorInterface $translator = null, $context = null)
    {
        return new StringTranslationException($message, $code, $previous, $subject, $translator, $context);
    }
326694
protected function createResponseException($actualCode, $respBody)
    {
        $exceptionCode    = $actualCode;
        $exceptionMessage = "Unexpected protobuf response code: " . $actualCode;

        if ($actualCode === RiakMessageCodes::ERROR_RESP) {
            $errorClass   = self::$respClassMap[$actualCode];
            $errorMessage = Protobuf::decode($errorClass, (string) $respBody);

            if ($errorMessage->hasErrmsg()) {
                $exceptionMessage  = $errorMessage->getErrmsg();
            }

            if ($errorMessage->hasErrcode()) {
                $exceptionCode = $errorMessage->getErrcode();
            }
        }

        return new RiakTransportException($exceptionMessage, $exceptionCode);
    }
595041
public static function invalidAssociation(ClassMetadata $targetClass, AssociationMetadata $association, $actualValue)
    {
        $expectedType = $targetClass->getClassName();

        return new self(sprintf(
            'Expected value of type "%s" for association field "%s#$%s", got "%s" instead.',
            $expectedType,
            $association->getSourceEntity(),
            $association->getName(),
            is_object($actualValue) ? get_class($actualValue) : gettype($actualValue)
        ));
    }
974972
public static function makeFromException($e, $overrideCode = null)
    {
        $code = $overrideCode === null ? $e->getCode() : $overrideCode;

        if ($e instanceof static) {
            $e->code = $code;

            return $e;
        }

        return new static($e->getMessage(), $code, $e);
    }
1142761
public static function fromValue(
        $expected_type,
        $actual_value,
        DeserializationContext $context = null
    ) {
        if (null !== $context && count($context->getCurrentPath()) > 0) {
            $property = sprintf('property "%s" to be ', implode('.', $context->getCurrentPath()));
        } else {
            $property = '';
        }

        return new static(sprintf(
            'Expected %s%s, but got %s: %s',
            $property,
            $expected_type,
            gettype($actual_value),
            json_encode($actual_value)
        ));
    }
533254
private void error(String expected, String actual) {
        if (!recovering) {
            recovering = true;
            final String outputString = (EOF_STRING.equals(actual) || UNTERMINATED_COMMENT_STRING.equals(actual) || COMMENT_NOT_ALLOWED.equals(actual)) ? actual : "'"
                    + actual + "'";
            errors.add(SyntaxError._UnexpectedToken(expected, outputString,
                    lookahead(1).beginLine));
        }
    }
757267
protected function assertMailCount($actualMail, $expectedCount = null)
    {
        $actualCount = count($actualMail);
        if (is_null($expectedCount)) {
            // If number to expect is not specified, expect more than zero.
            if ($actualCount === 0) {
                throw new \Exception("Expected some mail, but none found.");
            }
        } else {
            if ($expectedCount != $actualCount) {
                // Prepare a simple list of actual mail.
                $prettyActualMail = [];
                foreach ($actualMail as $singleActualMail) {
                    $prettyActualMail[] = [
                    'to' => $singleActualMail['to'],
                    'subject' => $singleActualMail['subject'],
                    ];
                }
                throw new \Exception(sprintf("Expected %s mail, but %s found:\n\n%s", $expectedCount, $actualCount, print_r($prettyActualMail, true)));
            }
        }
    }
1018748
public static function create(ConstraintViolationListInterface $violationList, $code = 0, \Exception $prev = null)
    {
        $violationMessages = [];

        /** @var \Symfony\Component\Validator\ConstraintViolationInterface $violation */
        foreach ($violationList as $violation) {
            $violationMessages[] = sprintf(
                '[%s]: %s;',
                $violation->getPropertyPath(),
                $violation->getMessage()
            );
        }

        $message = 'Not valid. ' . implode(' ', $violationMessages);

        return new static($violationList, $message, $code, $prev);
    }
1067343
protected function syntaxError($expectedDesc, $actualToken = null)
    {
        if (null === $actualToken) {
            $actualToken = $this->lexer->next;
        }
        if (null === $actualToken) {
            $actualDesc = 'end of input';
        } else if ($actualToken[1] === 0) {
            $actualDesc = sprintf('"%s" of type %s at beginning of input', $actualToken[0], $this->lexer->getName($actualToken[2]));
        } else {
            $actualDesc = sprintf('"%s" of type %s at position %d (0-based)', $actualToken[0], $this->lexer->getName($actualToken[2]), $actualToken[1]);
        }

        $ex = new SyntaxErrorException(sprintf('Expected %s, but got %s%s.', $expectedDesc, $actualDesc, $this->context ? ' '.$this->context : ''));
        if (null !== $actualToken) {
            $ex->setActualToken($actualToken);
        }
        if (null !== $this->context) {
            $ex->setContext($this->context);
        }

        throw $ex;
    }
816974
public static function match($actual, $expected = null)
    {
        $a = static::actual($actual);
        static::_buildDescription($a, $expected);

        return $a === $expected;
    }
1344591
public function notTypeOf($actual, $expected, $message = '')
    {
        $this->assertion->setActual($actual);

        return $this->assertion->to->not->be->a($expected, $message);
    }
708073
public static function errorToException($code){
    if(!isset(self::$codeMap[$code])){
      return new BadResponseException(sprintf(
        'Undefined error code "%s"',
        $code
      ));
    }
    $exceptionClass = self::$codeMap[$code];
    return  new $exceptionClass;
  }
610875
public static function match($actual, $expected)
    {
        $a = static::actual($actual);
        $e = static::expected($expected);

        static::_buildDescription($a, $e);
        return $a === $e;
    }
88368
protected function _createTranslationException($message, $code = 0, \Exception $previous = null, $subject = null, TranslatorInterface $translator = null)
    {
        return new TranslationException($message, $code, $previous, $subject, $translator);
    }
406522
public static function assertArrayEqualsNoOrder(
        $expected, $actual, $message='') {

          Assert::assertThat(
            $actual,
            new ArrayEqualsNoOrder($expected),
            $message);
    }
1315657
function Exception(code, message) {
    const factory = Object.create(Exception.prototype);
    factory.code = code;
    factory.message = message;
    factory.stack = factory.toString();
    return factory;
}