1 | <?php |
||
12 | class DomainTariffManager extends AbstractTariffManager |
||
13 | { |
||
14 | /** |
||
15 | * @var DomainTariffForm |
||
16 | */ |
||
17 | public $form; |
||
18 | |||
19 | /** |
||
20 | * @inheritdoc |
||
21 | */ |
||
22 | protected $type = 'domain'; |
||
23 | |||
24 | public function init() |
||
25 | { |
||
26 | parent::init(); |
||
27 | |||
28 | if (!Yii::getAlias('@domain', true)) { |
||
29 | throw new NotFoundHttpException('Domain module is missing'); |
||
30 | } |
||
31 | |||
32 | $this->formOptions['zones'] = $this->getZones(); |
||
33 | } |
||
34 | |||
35 | public function insert() |
||
36 | { |
||
37 | $data = $this->form->toArray(); |
||
38 | |||
39 | try { |
||
40 | $result = Tariff::perform('Create', $data); |
||
41 | } catch (ErrorResponseException $e) { |
||
42 | throw new UnprocessableEntityHttpException($e->getMessage(), 0, $e); |
||
43 | } |
||
44 | |||
45 | $this->form->id = $result['id']; |
||
46 | |||
47 | return true; |
||
48 | } |
||
49 | |||
50 | public function update() |
||
51 | { |
||
52 | $data = $this->form->toArray(); |
||
53 | |||
54 | try { |
||
55 | $result = Tariff::perform('Update', $data); |
||
|
|||
56 | } catch (ErrorResponseException $e) { |
||
57 | throw new UnprocessableEntityHttpException($e->getMessage(), 0, $e); |
||
58 | } |
||
59 | |||
60 | return true; |
||
61 | } |
||
62 | |||
63 | protected function getFormOptions() |
||
64 | { |
||
65 | return array_merge([ |
||
66 | 'class' => DomainTariffForm::class, |
||
67 | 'zones' => $this->getZones(), |
||
68 | ], parent::getFormOptions()); |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * @return array |
||
73 | */ |
||
74 | protected function getZones() |
||
78 | } |
||
79 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.