Completed
Pull Request — master (#573)
by Jeroen De
06:03
created

DoctrineMembershipApplicationPiwikTracker::getApplicationById()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 3
nop 1
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace WMDE\Fundraising\Frontend\DataAccess;
6
7
use WMDE\Fundraising\Entities\MembershipApplication;
8
use WMDE\Fundraising\Frontend\Infrastructure\MembershipApplicationPiwikTracker;
9
use WMDE\Fundraising\Frontend\Infrastructure\MembershipApplicationPiwikTrackingException;
10
use WMDE\Fundraising\Store\MembershipApplicationRepository;
11
use WMDE\Fundraising\Store\MembershipApplicationRepositoryException;
12
13
/**
14
 * @licence GNU GPL v2+
15
 * @author Jeroen De Dauw < [email protected] >
16
 */
17
class DoctrineMembershipApplicationPiwikTracker implements MembershipApplicationPiwikTracker {
18
19
	private $applicationModifier;
20
21
	public function __construct( MembershipApplicationRepository $applicationModifier ) {
22
		$this->applicationModifier = $applicationModifier;
23
	}
24
25
	public function trackApplication( int $applicationId, string $trackingString ) {
26
		try {
27
			$this->applicationModifier->modifyApplication(
28
				$applicationId,
29
				function( MembershipApplication $application ) use ( $trackingString ) {
30
					$application->setTracking( $trackingString );
31
				}
32
			);
33
		}
34
		catch ( MembershipApplicationRepositoryException $ex ) {
35
			throw new MembershipApplicationPiwikTrackingException( 'Could not update membership application' );
36
		}
37
	}
38
39
}
40