public function beforeBankgiroNode(BankgiroNode $node) { try { $node->setAttribute('account', $this->bankgiroFactory->createAccount($node->getValue())); } catch (BankingException $e) { $this->addError("Invalid bankgiro number %s on line %s", $node->getValue(), (string) $node->getLineNr()); } }
/** * Create a new parser */ public function createParser(int $flags = 0) : Parser { $flag = function (int $needle) use($flags) { return ($needle & $flags) == $needle; }; $processors = new MultiCore(new BankgiroProcessor(), new DateProcessor(), new FileProcessor(), new LayoutProcessor(), new MessageProcessor(), new PayeeProcessor()); if (!$flag(self::NO_ACCOUNT_PROCESSOR)) { $accountFactory = new AccountFactory(); $accountFactory->blacklistFormats([AccountFormats::FORMAT_PLUSGIRO]); $bankgiroFactory = new AccountFactory(); $bankgiroFactory->whitelistFormats([AccountFormats::FORMAT_BANKGIRO]); $processors->addProcessor(new AccountProcessor($accountFactory, $bankgiroFactory)); } if (!$flag(self::NO_AMOUNT_PROCESSOR)) { $processors->addProcessor(new AmountProcessor()); } if (!$flag(self::NO_ID_PROCESSOR)) { $processors->addProcessor(new IdProcessor(new OrganizationIdFactory(), new PersonalIdFactory(new CoordinationIdFactory(new NullIdFactory())))); } return new Parser(new Grammar(), $processors); }