DragonBe\Vies\Validator\ValidatorGB::validate PHP Method

validate() public method

public validate ( string $vatNumber ) : boolean
$vatNumber string
return boolean
    public function validate($vatNumber)
    {
        if (strlen($vatNumber) == 5) {
            return $this->validateGovernment($vatNumber);
        }
        if (strlen($vatNumber) != 9 && strlen($vatNumber) != 12) {
            return false;
        }
        $weights = array(8, 7, 6, 5, 4, 3, 2);
        $checkval = $this->sumWeights($weights, $vatNumber);
        $checkval += (int) substr($vatNumber, 7, 2);
        $Result1 = $checkval % 97;
        $Result2 = ($Result1 + 55) % 97;
        if ($Result1 * $Result2) {
            return false;
        }
        return true;
    }