AddDiscountExtension   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 16
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateForm() 0 13 2
1
<?php
2
3
namespace Broarm\EventTickets;
4
5
use Extension;
6
7
/**
8
 * Class AddDiscountExtension
9
 * @package Broarm\EventTickets
10
 * @property ReservationForm $owner
11
 */
12
class AddDiscountExtension extends Extension
13
{
14
    public function updateForm()
15
    {
16
        $fields = $this->owner->Fields();
17
        $reservation = $this->owner->getReservation();
18
        $event = $reservation->Event();
19
20
        if (!$event->DisableDiscountField) {
21
            $fields->add(
22
                $field = DiscountField::create('CouponCode', _t('DiscountForm.COUPON_CODE', 'Coupon code'))
23
            );
24
            $field->setForm($this->owner);
25
        }
26
    }
27
}
28