/** * Extracts the BC from an IBAN * * @param IBAN $iban * * @throws \InvalidArgumentException When the supplied IBAN is not from Switzerland */ public static function fromIBAN(IBAN $iban) { if ($iban->getCountry() !== 'CH') { throw new \InvalidArgumentException('BC can only be extracted from Swiss IBANs.'); } return new self(substr($iban->normalize(), 4, 5)); }