Validates opcode

@param $opcode

@return bool
775103
public static function validateOpcode($opcode)
    {
        switch ($opcode) { //Looks better than if & it's faster than in_array()
            case self::OPCODE_CONTINUE:
            case self::OPCODE_TEXT:
            case self::OPCODE_BINARY:
            case self::OPCODE_CLOSE:
            case self::OPCODE_PING:
            case self::OPCODE_PONG:
                return true;

            default:
                return false;
        }
    }
212355
public function hasCode($code)
    {
        if ($this->getException() !== null && $this->getException()->getCode() === $code) {
            return true;
        }

        foreach ($this->getErrors() as $message) {
            if ($message['code'] == $code) {
                return true;
            }
        }

        foreach ($this->getWarnings() as $message) {
            if ($message['code'] == $code) {
                return true;
            }
        }

        foreach ($this->getNotices() as $message) {
            if ($message['code'] == $code) {
                return true;
            }
        }

        return false;
    }
936218
public final static boolean canThrowException(byte opcode) {
        switch (opcode) {
        default:
            return false;
        case IALOAD:
        case LALOAD:
        case FALOAD:
        case DALOAD:
        case AALOAD:
        case BALOAD:
        case CALOAD:
        case SALOAD:
        case IASTORE:
        case LASTORE:
        case FASTORE:
        case DASTORE:
        case AASTORE:
        case BASTORE:
        case CASTORE:
        case SASTORE:
        case IDIV:
        case LDIV:
        case IREM:
        case LREM:
        case GETFIELD:
        case PUTFIELD:
        case INVOKEVIRTUAL:
        case INVOKESPECIAL:
        case INVOKESTATIC:
        case INVOKEINTERFACE:
        case NEWARRAY:
        case ANEWARRAY:
        case ARRAYLENGTH:
        case ATHROW:
        case CHECKCAST:
        case MONITORENTER:
        case MONITOREXIT:
        case MULTIANEWARRAY:
            return true;
        }
    }
1033245
public function confirmByCode($code)
    {
        $identity = ['confirmation_code' => $code];

        $account = $this->findByIdentity($identity);

        if($account){

            return $this->confirm($account);
        } else{

            return false;
        }
    }
1355906
protected static function checkDigitBarcode($code)
    {
        $tmp = Utils\Validation::mod11($code);

        $cd = ($tmp == 0 || $tmp == 1 || $tmp == 10)
            ? 1
            : 11 - $tmp;

        return $cd;
    }
65848
public static function isValid($code)
    {
        $features = config('laraplans.features');

        if (array_key_exists($code, $features)) {
            return true;
        }

        if (in_array($code, $features)) {
            return true;
        }

        return false;
    }
235356
public function check($code) {
        $code = trim($code);
        // last token should be ;
        if(substr($code, -1) != ';') {
            $this->error = ['line' => (substr_count($code, "\n") + 1), 'prev' => ']', 'token' => ';', 'must' => true];
            return false;
        }
        // exclude last token
        $code = substr($code, 0, -1);
        // get all tokens
        $tokens = token_get_all($code);
        $prev = false;
        $this->error['line'] = false;
        foreach($tokens as $token) {
            if(is_array($token)) {
                $tn = token_name($token['0']);
                if(in_array($tn, ['T_WHITESPACE', 'T_COMMENT']))
                    continue;
                $this->error = ['line' => $token[2], 'prev' => $prev, 'token' => $tn];
                if(!in_array($tn, self::$valid_tokens))
                    return false;
                elseif($tn == 'T_STRING' && !in_array(strtolower($token[1]), ['true', 'false']))
                    return false;
                if($this->validSequence($prev, $tn))
                   $prev = $tn;
                else
                    return false; 
            } else {
                // line will be defined in any case, so no needed to define it here 
                $this->error['prev'] = $prev;
                $this->error['token'] = $token;
                if(in_array($token, self::$valid_symbols) && $this->validSequence($prev, $token))
                    $prev = $token;
                else
                    return false;
            }
        }
        // chek pairs of $braces
        $braces = 0;
        $inString = 0;
        $this->error['line'] = 0;
        foreach($tokens as $token) {
            if($inString & 1) {
                switch ($token) {
                    case '`':
                    case '"': --$inString; break;
                }
            } else {
                switch ($token) {
                    case '`':
                    case '"': ++$inString; break;
     
                    case '[': case '(': ++$braces; break;
                    case ']': case ')':
                        if ($inString) {
                            --$inString;
                        }
                        else {
                            --$braces;
                            if ($braces < 0) {
                                return false;
                            }
                        }
                    break;
                }
            }
        }
        if ($braces) {
            return false;
        }
        return true;
    }
1140213
public static function validate($code = '', $key = -1)
    {
        if (strlen($key) < 1) {
            return false;
        }

        if (!is_numeric($key)) {
            return false;
        }

        if (!is_string($code)) {
            return false;
        }

        if (strlen($code) < 2) {
            return false;
        }

        $numerals = str_split($code);
        $rank = array_reverse(array_keys($numerals));
        $orderedNumerals = array();
        foreach ($rank as $i => $rankValue) {
            $orderedNumerals[$rankValue + 1] = $numerals[$i];
        }
        $results = array();
        foreach ($orderedNumerals as $cle => $value) {
            $results[$value] = ($cle % 2 == 0) ? ((int) $value * 1) : ((int) $value * 2);
        }
        $sum = 0;
        foreach ($results as $cle => $value) {
            $sum += array_sum(str_split($value));
        }
        $validKey = str_split($sum);
        $validKey = 10 - array_pop($validKey);

        return $key === $validKey;
    }
330466
public function validate($postcode)
    {
        $url = '/postcodes/' . rawurlencode($postcode) . '/validate';
        $request = new Request('GET', $url);
        $response = $this->httpTransport($request);

        return ($response && (200 === $response->status) && $response->result);
    }
168671
protected function validate($code)
    {
        $color = str_replace(['rgb', '(', ')', ' '], '', DefinedColor::find($code, 1));
        if (preg_match('/^(\d{1,3}),(\d{1,3}),(\d{1,3})$/', $color, $matches)) {
            if ($matches[1] > 255 || $matches[2] > 255 || $matches[3] > 255) {
                return false;
            }
            return $color;
        }
        return false;
    }
1096486
public static function validateNewPersonCode(string $personCode): bool
    {
        $personCode = str_replace('-', '', $personCode);
        // @formatter:off
        $calculations = [1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
        // @formatter:on
        $sum = 0;
        foreach ($calculations as $key => $calculation) {
            $sum += ($personCode[$key] * $calculation);
        }
        $remainder = $sum % 11;
        if (1 - $remainder < -1) {
            return (int)$personCode[10] === (1 - $remainder + 11);
        }

        return (int)$personCode[10] === (1 - $remainder);
    }
177043
static void checkOpcode(final int opcode, final int type) {
        if (opcode < 0 || opcode > 199 || TYPE[opcode] != type) {
            throw new IllegalArgumentException("Invalid opcode: " + opcode);
        }
    }
840411
private function codecIsValid(string $codec): bool
    {
        return in_array(
            $codec, //@codeCoverageIgnore
            [
                IbmWatsonAudioFormatsInterface::CODEC_OPUS,
                IbmWatsonAudioFormatsInterface::CODEC_VORBIS
            ]
        );
    }
689302
protected static function isBase64Valid(string $encode): bool
    {
        $decode = base64_decode($encode, true);

        if (false === $decode) {
            return false;
        }

        return base64_encode($decode) === $encode;
    }
1353612
protected function validateStatusCode(int $code): int
    {
        if (!is_numeric($code) || is_float($code) || 100 > $code || 599 < $code) {
            throw new InvalidStatusException(
                'Invalid status code. Must be an integer between 100 and 599, inclusive.'
            );
        }

        return $code;
    }
892254
public static function validateOldPersonCode(string $personCode): bool
    {
        $personCode = str_replace('-', '', $personCode);
        $check = '01060307091005080402';
        $checksum = 1;
        for ($i = 0; $i < 10; $i++) {
            $checksum -= (int)$personCode[$i] * (int)substr($check, $i * 2, 2);
        }

        return !((int)($checksum - floor($checksum / 11) * 11) !== (int)$personCode[10]);
    }
1244880
public function errorCode()
    {
        if (!$this->_stmt) {
            return false;
        }

        $error = oci_error($this->_stmt);

        if (!$error) {
            return false;
        }

        return $error['code'];
    }