Completed
Pull Request — master (#1473)
by Tim
31:22 queued 01:19
created

__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 3
dl 0
loc 4
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace WMDE\Fundraising\Frontend\Infrastructure\Mail;
6
7
use Symfony\Component\Translation\TranslatorInterface;
8
use WMDE\Fundraising\PaymentContext\Domain\Model\PaymentMethod;
9
10
/**
11
 * @license GNU GPL v2+
12
 */
13
class DonationConfirmationMailSubjectRenderer implements MailSubjectRendererInterface {
14
15
	private $translator;
16
	private $defaultSubjectKey;
17
	private $bankTransferSubjectKey;
18
19 44
	public function __construct( TranslatorInterface $translator, string $defaultSubjectKey, string $bankTransferSubjectKey ) {
20 44
		$this->translator = $translator;
21 44
		$this->defaultSubjectKey = $defaultSubjectKey;
22 44
		$this->bankTransferSubjectKey = $bankTransferSubjectKey;
23 44
	}
24
25 21
	public function render( array $templateArguments = [] ): string {
26 21
		if ( $templateArguments['donation']['paymentType'] === PaymentMethod::BANK_TRANSFER ) {
27 2
			return $this->translator->trans( $this->bankTransferSubjectKey );
28
		}
29 19
		return $this->translator->trans( $this->defaultSubjectKey );
30
	}
31
32
}
33