Conditions | 6 |
Paths | 3 |
Total Lines | 55 |
Code Lines | 37 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
35 | public function generatePDF(PaymentOrder $paymentOrder): string |
||
36 | { |
||
37 | if (null === $paymentOrder->getDepartment()) { |
||
38 | throw new LogicException('$paymentOrder must have an associated department!'); |
||
39 | } |
||
40 | |||
41 | $pdf = new SturaPDF(); |
||
42 | $pdf->setAuthor('StuRa FSU Jena'); |
||
43 | $pdf->setTitle('Zahlungsauftrag #'.$paymentOrder->getId()); |
||
44 | $pdf->setSubject('Zahlungsauftrag'); |
||
45 | $pdf->SetAutoPageBreak(false); |
||
46 | |||
47 | $pdf->AddPage(); |
||
48 | |||
49 | $pdf->setY(80); |
||
50 | $pdf->setMargins(25, 10); |
||
51 | |||
52 | $pdf->writeHTML('<h1>Zahlungsauftrag #'.$paymentOrder->getId().'</h1><br>'); |
||
53 | |||
54 | $this->writeRow($pdf, 'Name des Zahlungsempfängers', $paymentOrder->getFullName()); |
||
55 | $this->writeRow($pdf, 'Struktur / Organisation', $paymentOrder->getDepartment()->getName()); |
||
56 | $this->writeRow($pdf, 'Projektbezeichnung', $paymentOrder->getProjectName()); |
||
57 | $this->writeRow($pdf, 'Betrag', $paymentOrder->getAmountString().' €'); |
||
58 | $this->writeRow($pdf, 'Mittelfreigabe / Finanzantrag', !empty($paymentOrder->getFundingId()) ? $paymentOrder->getFundingId() : '<i>Nicht angegeben</i>'); |
||
59 | $this->writeRow($pdf, 'FSR-Kom Antrag', $paymentOrder->isFsrKomResolution() ? 'Ja' : 'Nein'); |
||
60 | $formatter = new IntlDateFormatter('de_DE', IntlDateFormatter::MEDIUM, IntlDateFormatter::NONE); |
||
61 | $this->writeRow($pdf, 'Beschlussdatum', null === $paymentOrder->getResolutionDate() ? '<i>Nicht angegeben</i>' : $formatter->format($paymentOrder->getResolutionDate())); |
||
62 | |||
63 | $pdf->Ln(); |
||
64 | |||
65 | $this->writeRow($pdf, 'Kontoinhaber*in', $paymentOrder->getBankInfo()->getAccountOwner()); |
||
66 | $this->writeRow($pdf, 'Straße/Nr.', $paymentOrder->getBankInfo()->getStreet()); |
||
67 | $this->writeRow($pdf, 'PLZ/Ort', $paymentOrder->getBankInfo()->getZipCode().' '.$paymentOrder->getBankInfo()->getCity()); |
||
68 | $this->writeRow($pdf, 'IBAN', $paymentOrder->getBankInfo()->getIban()); |
||
69 | $this->writeRow($pdf, 'BIC', $paymentOrder->getBankInfo()->getBic()); |
||
70 | $this->writeRow($pdf, 'Bank', $paymentOrder->getBankInfo()->getBankName()); |
||
71 | $this->writeRow($pdf, 'Verwendungszweck', $paymentOrder->getBankInfo()->getReference()); |
||
72 | |||
73 | $pdf->Ln(); |
||
74 | $formatter = new IntlDateFormatter('de-DE', IntlDateFormatter::MEDIUM, IntlDateFormatter::MEDIUM); |
||
75 | $this->writeRow($pdf, 'Einreichungsdatum', $formatter->format($paymentOrder->getCreationDate())); |
||
76 | |||
77 | $pdf->Ln(15); |
||
78 | $pdf->writeHTML('Dieses Dokument muss <i>ausgedruckt</i> und <i>unterschrieben</i> werden und wird dann zusammen mit den Belegen abgeheftet |
||
79 | und mit dem Jahresabschluss beim StuRa abgegeben!'); |
||
80 | $pdf->writeHTML('Mit meiner Unterschrift erkläre ich, dass die Angaben hier korrekt sind und ich alle Belege vorliegen habe.'); |
||
81 | |||
82 | if ($paymentOrder->getDepartment()->isFSR()) { |
||
83 | $pdf->Ln(20); |
||
84 | $this->addSignatureField($pdf, 'Datum, Unterschrift FSR Verantwortliche', false); |
||
85 | } |
||
86 | |||
87 | //$pdf->MultiCell(0,0, 'Name:', 0, 'L', ) |
||
88 | |||
89 | return $pdf->Output('doc.pdf', 'S'); |
||
90 | } |
||
103 |