1 | <?php |
||
2 | /** |
||
3 | * FinTSJobConfiguration.php |
||
4 | * Copyright (c) 2019 https://github.com/bnw |
||
5 | * |
||
6 | * This file is part of Firefly III (https://github.com/firefly-iii). |
||
7 | * |
||
8 | * This program is free software: you can redistribute it and/or modify |
||
9 | * it under the terms of the GNU Affero General Public License as |
||
10 | * published by the Free Software Foundation, either version 3 of the |
||
11 | * License, or (at your option) any later version. |
||
12 | * |
||
13 | * This program is distributed in the hope that it will be useful, |
||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
16 | * GNU Affero General Public License for more details. |
||
17 | * |
||
18 | * You should have received a copy of the GNU Affero General Public License |
||
19 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
||
20 | */ |
||
21 | declare(strict_types=1); |
||
22 | |||
23 | namespace FireflyIII\Import\JobConfiguration; |
||
24 | |||
25 | use FireflyIII\Exceptions\FireflyException; |
||
26 | use FireflyIII\Models\ImportJob; |
||
27 | use FireflyIII\Support\Import\JobConfiguration\FinTS\ChooseAccountHandler; |
||
28 | use FireflyIII\Support\Import\JobConfiguration\FinTS\FinTSConfigurationInterface; |
||
29 | use FireflyIII\Support\Import\JobConfiguration\FinTS\NewFinTSJobHandler; |
||
30 | use Illuminate\Support\MessageBag; |
||
31 | |||
32 | /** |
||
33 | * |
||
34 | * Class FinTSJobConfiguration |
||
35 | * |
||
36 | * @deprecated |
||
37 | * @codeCoverageIgnore |
||
38 | */ |
||
39 | class FinTSJobConfiguration implements JobConfigurationInterface |
||
0 ignored issues
–
show
|
|||
40 | { |
||
41 | /** @var ImportJob */ |
||
42 | private $importJob; |
||
43 | |||
44 | /** |
||
45 | * Returns true when the initial configuration for this job is complete. |
||
46 | * |
||
47 | * @return bool |
||
48 | */ |
||
49 | public function configurationComplete(): bool |
||
50 | { |
||
51 | return $this->importJob->stage === FinTSConfigurationSteps::GO_FOR_IMPORT; |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * Store any data from the $data array into the job. Anything in the message bag will be flashed |
||
56 | * as an error to the user, regardless of its content. |
||
57 | * |
||
58 | * @param array $data |
||
59 | * |
||
60 | * @throws FireflyException |
||
61 | * @return MessageBag |
||
62 | */ |
||
63 | public function configureJob(array $data): MessageBag |
||
64 | { |
||
65 | return $this->getConfigurationObject()->configureJob($data); |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * Return the data required for the next step in the job configuration. |
||
70 | * |
||
71 | * @throws FireflyException |
||
72 | * @return array |
||
73 | */ |
||
74 | public function getNextData(): array |
||
75 | { |
||
76 | return $this->getConfigurationObject()->getNextData(); |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * Returns the view of the next step in the job configuration. |
||
81 | * |
||
82 | * @throws FireflyException |
||
83 | * @return string |
||
84 | */ |
||
85 | public function getNextView(): string |
||
86 | { |
||
87 | switch ($this->importJob->stage) { |
||
88 | case FinTSConfigurationSteps::NEW: |
||
89 | case FinTSConfigurationSteps::CHOOSE_ACCOUNT: |
||
90 | return 'import.fints.' . $this->importJob->stage; |
||
91 | break; |
||
0 ignored issues
–
show
break is not strictly necessary here and could be removed.
The switch ($x) {
case 1:
return 'foo';
break; // This break is not necessary and can be left off.
}
If you would like to keep this construct to be consistent with other
Loading history...
|
|||
92 | default: |
||
93 | // @codeCoverageIgnoreStart |
||
94 | throw new FireflyException( |
||
95 | sprintf('FinTSJobConfiguration::getNextView() cannot handle stage "%s"', $this->importJob->stage) |
||
96 | ); |
||
97 | // @codeCoverageIgnoreEnd |
||
98 | } |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * @param ImportJob $importJob |
||
103 | */ |
||
104 | public function setImportJob(ImportJob $importJob): void |
||
105 | { |
||
106 | $this->importJob = $importJob; |
||
107 | } |
||
108 | |||
109 | /** |
||
110 | * Get the configuration handler for this specific stage. |
||
111 | * |
||
112 | * @throws FireflyException |
||
113 | * @return FinTSConfigurationInterface |
||
114 | */ |
||
115 | private function getConfigurationObject(): FinTSConfigurationInterface |
||
116 | { |
||
117 | $class = 'DoNotExist'; |
||
118 | switch ($this->importJob->stage) { |
||
119 | case FinTSConfigurationSteps::NEW: |
||
120 | $class = NewFinTSJobHandler::class; |
||
121 | break; |
||
122 | case FinTSConfigurationSteps::CHOOSE_ACCOUNT: |
||
123 | $class = ChooseAccountHandler::class; |
||
124 | break; |
||
125 | } |
||
126 | if (!class_exists($class)) { |
||
127 | throw new FireflyException(sprintf('Class %s does not exist in getConfigurationClass().', $class)); // @codeCoverageIgnore |
||
128 | } |
||
129 | |||
130 | $configurator = app($class); |
||
131 | $configurator->setImportJob($this->importJob); |
||
132 | |||
133 | return $configurator; |
||
134 | } |
||
135 | |||
136 | |||
137 | } |
||
138 |
This interface has been deprecated. The supplier of the interface has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the interface will be removed and what other interface to use instead.