Completed
Push — master ( 133224...e0920c )
by Tim
11s
created

Subject::getFilesystemAdapter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * TechDivision\Import\Configuration\Jms\Configuration\Subject
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2016 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import-configuration-jms
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Configuration\Jms\Configuration;
22
23
use JMS\Serializer\Annotation\Type;
24
use JMS\Serializer\Annotation\SerializedName;
25
use JMS\Serializer\Annotation\PostDeserialize;
26
use TechDivision\Import\ConfigurationInterface;
27
use TechDivision\Import\Configuration\SubjectConfigurationInterface;
28
use TechDivision\Import\Configuration\Jms\Configuration\Subject\ImportAdapter;
29
use TechDivision\Import\Configuration\Jms\Configuration\Subject\ExportAdapter;
30
use TechDivision\Import\Configuration\Jms\Configuration\Subject\FilesystemAdapter;
31
32
/**
33
 * The subject configuration implementation.
34
 *
35
 * @author    Tim Wagner <[email protected]>
36
 * @copyright 2016 TechDivision GmbH <[email protected]>
37
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
38
 * @link      https://github.com/techdivision/import-configuration-jms
39
 * @link      http://www.techdivision.com
40
 */
41
class Subject implements SubjectConfigurationInterface
42
{
43
44
    /**
45
     * The trait that provides parameter handling functionality.
46
     *
47
     * @var \TechDivision\Import\Configuration\Jms\Configuration\ParamsTrait
48
     */
49
    use ParamsTrait;
50
51
    /**
52
     * The subject's unique DI identifier.
53
     *
54
     * @var string
55
     * @Type("string")
56
     * @SerializedName("id")
57
     */
58
    protected $id;
59
60
    /**
61
     * The file prefix for import files.
62
     *
63
     * @var string
64
     * @Type("string")
65
     */
66
    protected $prefix = 'magento-import';
67
68
    /**
69
     * The file suffix for import files.
70
     *
71
     * @var string
72
     * @Type("string")
73
     */
74
    protected $suffix = 'csv';
75
76
    /**
77
     * The array with the subject's observers.
78
     *
79
     * @var array
80
     * @Type("array")
81
     */
82
    protected $observers = array();
83
84
    /**
85
     * The array with the subject's callbacks.
86
     *
87
     * @var array
88
     * @Type("array<string, array>")
89
     */
90
    protected $callbacks = array();
91
92
    /**
93
     * A reference to the parent configuration instance.
94
     *
95
     * @var \TechDivision\Import\ConfigurationInterface
96
     */
97
    protected $configuration;
98
99
    /**
100
     * The flag to signal that the subjects needs a OK file to be processed or not.
101
     *
102
     * @var boolean
103
     * @Type("boolean")
104
     * @SerializedName("ok-file-needed")
105
     */
106
    protected $okFileNeeded = false;
107
108
    /**
109
     * The import adapter configuration instance.
110
     *
111
     * @var \TechDivision\Import\Configuration\Subject\ImportAdapterConfigurationInterface
112
     * @Type("TechDivision\Import\Configuration\Jms\Configuration\Subject\ImportAdapter")
113
     * @SerializedName("import-adapter")
114
     */
115
    protected $importAdapter;
116
117
    /**
118
     * The export adapter configuration instance.
119
     *
120
     * @var \TechDivision\Import\Configuration\Subject\ExportAdapterConfigurationInterface
121
     * @Type("TechDivision\Import\Configuration\Jms\Configuration\Subject\ExportAdapter")
122
     * @SerializedName("export-adapter")
123
     */
124
    protected $exportAdapter;
125
126
    /**
127
     * The filesystem adapter configuration instance.
128
     *
129
     * @var \TechDivision\Import\Configuration\Subject\FilesystemAdapterConfigurationInterface
130
     * @Type("TechDivision\Import\Configuration\Jms\Configuration\Subject\FilesystemAdapter")
131
     * @SerializedName("filesystem-adapter")
132
     */
133
    protected $filesystemAdapter;
134
135
    /**
136
     * Lifecycle callback that will be invoked after deserialization.
137
     *
138
     * @return void
139
     * @PostDeserialize
140
     */
141
    public function postDeserialize()
142
    {
143
144
        // set a default import adatper if none has been configured
145
        if ($this->importAdapter === null) {
146
            $this->importAdapter = new ImportAdapter();
147
        }
148
149
        // set a default export adatper if none has been configured
150
        if ($this->exportAdapter === null) {
151
            $this->exportAdapter = new ExportAdapter();
152
        }
153
154
        // set a default filesystem adatper if none has been configured
155
        if ($this->filesystemAdapter === null) {
156
            $this->filesystemAdapter = new FilesystemAdapter();
157
        }
158
    }
159
160
    /**
161
     * Return's the multiple field delimiter character to use, default value is comma (,).
162
     *
163
     * @return string The multiple field delimiter character
164
     */
165
    public function getMultipleFieldDelimiter()
166
    {
167
        return $this->getConfiguration()->getMultipleFieldDelimiter();
168
    }
169
170
    /**
171
     * Return's the multiple value delimiter character to use, default value is comma (|).
172
     *
173
     * @return string The multiple value delimiter character
174
     */
175
    public function getMultipleValueDelimiter()
176
    {
177
        return $this->getConfiguration()->getMultipleValueDelimiter();
178
    }
179
180
    /**
181
     * Return's the delimiter character to use, default value is comma (,).
182
     *
183
     * @return string The delimiter character
184
     */
185
    public function getDelimiter()
186
    {
187
        return $this->getConfiguration()->getDelimiter();
188
    }
189
190
    /**
191
     * The enclosure character to use, default value is double quotation (").
192
     *
193
     * @return string The enclosure character
194
     */
195
    public function getEnclosure()
196
    {
197
        return $this->getConfiguration()->getEnclosure();
198
    }
199
200
    /**
201
     * The escape character to use, default value is backslash (\).
202
     *
203
     * @return string The escape character
204
     */
205
    public function getEscape()
206
    {
207
        return $this->getConfiguration()->getEscape();
208
    }
209
210
    /**
211
     * The file encoding of the CSV source file, default value is UTF-8.
212
     *
213
     * @return string The charset used by the CSV source file
214
     */
215
    public function getFromCharset()
216
    {
217
        return $this->getConfiguration()->getFromCharset();
218
    }
219
220
    /**
221
     * The file encoding of the CSV targetfile, default value is UTF-8.
222
     *
223
     * @return string The charset used by the CSV target file
224
     */
225
    public function getToCharset()
226
    {
227
        return $this->getConfiguration()->getToCharset();
228
    }
229
230
    /**
231
     * The file mode of the CSV target file, either one of write or append, default is write.
232
     *
233
     * @return string The file mode of the CSV target file
234
     */
235
    public function getFileMode()
236
    {
237
        return $this->getConfiguration()->getFileMode();
238
    }
239
240
    /**
241
     * Queries whether or not strict mode is enabled or not, default is TRUE.
242
     *
243
     * @return boolean TRUE if strict mode is enabled, else FALSE
244
     */
245
    public function isStrictMode()
246
    {
247
        return $this->getConfiguration()->isStrictMode();
248
    }
249
250
    /**
251
     * Return's the subject's source date format to use.
252
     *
253
     * @return string The source date format
254
     */
255
    public function getSourceDateFormat()
256
    {
257
        return $this->getConfiguration()->getSourceDateFormat();
258
    }
259
260
    /**
261
     * Return's the source directory that has to be watched for new files.
262
     *
263
     * @return string The source directory
264
     */
265
    public function getSourceDir()
266
    {
267
        return $this->getConfiguration()->getSourceDir();
268
    }
269
270
    /**
271
     * Return's the target directory with the files that has been imported.
272
     *
273
     * @return string The target directory
274
     */
275
    public function getTargetDir()
276
    {
277
        return $this->getConfiguration()->getTargetDir();
278
    }
279
280
    /**
281
     * Queries whether or not debug mode is enabled or not, default is TRUE.
282
     *
283
     * @return boolean TRUE if debug mode is enabled, else FALSE
284
     */
285
    public function isDebugMode()
286
    {
287
        return $this->getConfiguration()->isDebugMode();
288
    }
289
290
    /**
291
     * Return's the subject's unique DI identifier.
292
     *
293
     * @return string The subject's unique DI identifier
294
     */
295
    public function getId()
296
    {
297
        return $this->id;
298
    }
299
300
    /**
301
     * Set's the reference to the configuration instance.
302
     *
303
     * @param \TechDivision\Import\ConfigurationInterface $configuration The configuration instance
304
     *
305
     * @return void
306
     */
307
    public function setConfiguration(ConfigurationInterface $configuration)
308
    {
309
        $this->configuration = $configuration;
310
    }
311
312
    /**
313
     * Return's the reference to the configuration instance.
314
     *
315
     * @return \TechDivision\Import\ConfigurationInterface The configuration instance
316
     */
317
    public function getConfiguration()
318
    {
319
        return $this->configuration;
320
    }
321
322
    /**
323
     * Set's the prefix for the import files.
324
     *
325
     * @param string $prefix The prefix
326
     *
327
     * @return void
328
     */
329
    public function setPrefix($prefix)
330
    {
331
        $this->prefix = $prefix;
332
    }
333
334
    /**
335
     * Return's the prefix for the import files.
336
     *
337
     * @return string The prefix
338
     */
339
    public function getPrefix()
340
    {
341
        return $this->prefix;
342
    }
343
344
    /**
345
     * Set's the suffix for the import files.
346
     *
347
     * @param string $suffix The suffix
348
     *
349
     * @return void
350
     */
351
    public function setSuffix($suffix)
352
    {
353
        $this->suffix = $suffix;
354
    }
355
356
    /**
357
     * Return's the suffix for the import files.
358
     *
359
     * @return string The suffix
360
     */
361
    public function getSuffix()
362
    {
363
        return $this->suffix;
364
    }
365
366
    /**
367
     * Return's the array with the subject's observers.
368
     *
369
     * @return array The subject's observers
370
     */
371
    public function getObservers()
372
    {
373
        return $this->observers;
374
    }
375
376
    /**
377
     * Return's the array with the subject's callbacks.
378
     *
379
     * @return array The subject's callbacks
380
     */
381
    public function getCallbacks()
382
    {
383
        return $this->callbacks;
384
    }
385
386
    /**
387
     * Set's the flag to signal that the an OK file is needed for the subject
388
     * to be processed.
389
     *
390
     * @param boolean $okFileNeeded TRUE if the subject needs an OK file, else FALSE
391
     *
392
     * @return void
393
     */
394
    public function setOkFileNeeded($okFileNeeded)
395
    {
396
        $this->okFileNeeded = $okFileNeeded;
397
    }
398
399
    /**
400
     * Queries whether or not that the subject needs an OK file to be processed.
401
     *
402
     * @return boolean TRUE if the subject needs an OK file, else FALSE
403
     */
404
    public function isOkFileNeeded()
405
    {
406
        return $this->okFileNeeded;
407
    }
408
409
    /**
410
     * Return's the import adapter configuration instance.
411
     *
412
     * @return \TechDivision\Import\Configuration\Subject\ImportAdapterConfigurationInterface The import adapter configuration instance
413
     */
414
    public function getImportAdapter()
415
    {
416
        return $this->importAdapter;
417
    }
418
419
    /**
420
     * Return's the export adapter configuration instance.
421
     *
422
     * @return \TechDivision\Import\Configuration\Subject\ExportAdapterConfigurationInterface The export adapter configuration instance
423
     */
424
    public function getExportAdapter()
425
    {
426
        return $this->exportAdapter;
427
    }
428
429
    /**
430
     * Return's the filesystem adapter configuration instance.
431
     *
432
     * @return \TechDivision\Import\Configuration\Subject\FilesystemAdapterConfigurationInterface The filesystem adapter configuration instance
433
     */
434
    public function getFilesystemAdapter()
435
    {
436
        return $this->filesystemAdapter;
437
    }
438
}
439