ExtensionStruct   F
last analyzed

Complexity

Total Complexity 85

Size/Duplication

Total Lines 589
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 136
dl 0
loc 589
rs 2
c 0
b 0
f 0
wmc 85

81 Methods

Rating   Name   Duplication   Size   Complexity  
A setVersion() 0 3 1
A setNotices() 0 3 1
A fromArray() 0 15 4
A setShortDescription() 0 3 1
A setVariants() 0 3 1
A getDomains() 0 3 1
A getStoreLicense() 0 3 1
A getCategorizedPermissions() 0 7 2
A setName() 0 3 1
A setPermissions() 0 3 1
A getDescription() 0 3 1
A setDomains() 0 3 1
A getUpdateSource() 0 3 1
A setIconRaw() 0 3 1
A getImages() 0 3 1
A isTheme() 0 3 1
A getLastUpdateDate() 0 3 1
A getActive() 0 3 1
A setLocalId() 0 3 1
A getPrivacyPolicyLink() 0 3 1
A setUpdatedAt() 0 3 1
A getIcon() 0 3 1
A setImages() 0 3 1
A setDescription() 0 3 1
A getLocalId() 0 3 1
A setProducerWebsite() 0 3 1
A getInstalledAt() 0 3 1
A isAllowDisable() 0 3 1
A setPrivacyPolicyLink() 0 3 1
A setProducerName() 0 3 1
A getCategories() 0 3 1
A getNotices() 0 3 1
A setStoreUrl() 0 3 1
A isConfigurable() 0 3 1
A setIsTheme() 0 3 1
A setPrivacyPolicyExtension() 0 3 1
A getSource() 0 3 1
A jsonSerialize() 0 6 1
A getProducerWebsite() 0 3 1
A setId() 0 3 1
A getBinaries() 0 3 1
A getStoreExtension() 0 3 1
A getStoreUrl() 0 3 1
A getLabel() 0 3 1
A getProducerName() 0 3 1
A setInstalledAt() 0 3 1
A setLatestVersion() 0 3 1
A getPermissions() 0 3 1
A setLabel() 0 3 1
A getPrivacyPolicyExtension() 0 3 1
A getLanguages() 0 3 1
A getUpdatedAt() 0 3 1
A setFaq() 0 3 1
A setBinaries() 0 3 1
A setRating() 0 3 1
A getVersion() 0 3 1
A setStoreExtension() 0 3 1
A getName() 0 3 1
A setAllowDisable() 0 3 1
A setNumberOfRatings() 0 3 1
A setLanguages() 0 3 1
A getLicense() 0 3 1
A setConfigurable() 0 3 1
A getFaq() 0 3 1
A setType() 0 3 1
A getNumberOfRatings() 0 3 1
A getRating() 0 3 1
A getVariants() 0 3 1
A getIconRaw() 0 3 1
A setLastUpdateDate() 0 3 1
A setSource() 0 3 1
A setIcon() 0 3 1
A setActive() 0 3 1
A setUpdateSource() 0 3 1
A getId() 0 3 1
A setStoreLicense() 0 3 1
A getLatestVersion() 0 3 1
A setLicense() 0 3 1
A getShortDescription() 0 3 1
A setCategories() 0 3 1
A getType() 0 3 1

How to fix   Complexity   

Complex Class

Complex classes like ExtensionStruct often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use ExtensionStruct, and based on these observations, apply Extract Interface, too.

1
<?php declare(strict_types=1);
2
3
namespace Shopware\Core\Framework\Store\Struct;
4
5
use Shopware\Core\Framework\App\AppEntity;
0 ignored issues
show
Bug introduced by
The type Shopware\Core\Framework\App\AppEntity was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Shopware\Core\Framework\Log\Package;
7
use Shopware\Core\Framework\Plugin\PluginEntity;
0 ignored issues
show
Bug introduced by
The type Shopware\Core\Framework\Plugin\PluginEntity was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Shopware\Core\Framework\Struct\Struct;
9
10
/**
11
 * @codeCoverageIgnore
12
 */
13
#[Package('services-settings')]
14
class ExtensionStruct extends Struct
15
{
16
    final public const EXTENSION_TYPE_APP = 'app';
17
    final public const EXTENSION_TYPE_PLUGIN = 'plugin';
18
    final public const SOURCE_LOCAL = 'local';
19
    final public const SOURCE_STORE = 'store';
20
21
    protected ?int $id = null;
22
23
    protected ?string $localId = null;
24
25
    /**
26
     * @see AppEntity::$name
27
     * @see PluginEntity::$name
28
     */
29
    protected string $name;
30
31
    /**
32
     * @see AppEntity::$label
33
     * @see PluginEntity::$label
34
     */
35
    protected string $label;
36
37
    /**
38
     * @see AppEntity::$description
39
     * @see PluginEntity::$description
40
     */
41
    protected ?string $description = null;
42
43
    protected ?string $shortDescription = null;
44
45
    /**
46
     * @see AppEntity::$author
47
     * @see PluginEntity::$author
48
     */
49
    protected ?string $producerName = null;
50
51
    /**
52
     * @see AppEntity::$license
53
     * @see PluginEntity::$license
54
     */
55
    protected ?string $license = null;
56
57
    /**
58
     * @see AppEntity::$version
59
     * @see PluginEntity::$version
60
     */
61
    protected ?string $version = null;
62
63
    protected ?string $latestVersion = null;
64
65
    /**
66
     * privacyPolicyLink from store
67
     *
68
     * @see AppEntity::$privacy
69
     */
70
    protected ?string $privacyPolicyLink = null;
71
72
    /**
73
     * languages property from store
74
     *
75
     * @var array<string>
76
     */
77
    protected array $languages = [];
78
79
    protected ?float $rating = null;
80
81
    protected int $numberOfRatings = 0;
82
83
    protected ?VariantCollection $variants = null;
84
85
    protected ?FaqCollection $faq = null;
86
87
    protected ?BinaryCollection $binaries = null;
88
89
    protected ?ImageCollection $images = null;
90
91
    protected ?string $icon = null;
92
93
    protected ?string $iconRaw = null;
94
95
    protected ?StoreCategoryCollection $categories = null;
96
97
    protected ?PermissionCollection $permissions = null;
98
99
    protected bool $active = false;
100
101
    /**
102
     * @var string 'app' | 'plugin'
103
     */
104
    protected string $type;
105
106
    protected bool $isTheme = false;
107
108
    /**
109
     * @see AppEntity::$configurable
110
     */
111
    protected bool $configurable = false;
112
113
    /**
114
     * @see AppEntity::$privacyPolicyExtensions
115
     */
116
    protected ?string $privacyPolicyExtension = null;
117
118
    protected ?LicenseStruct $storeLicense = null;
119
120
    protected ?ExtensionStruct $storeExtension = null;
121
122
    protected ?\DateTimeInterface $installedAt = null;
123
124
    protected ?\DateTimeInterface $updatedAt = null;
125
126
    /**
127
     * @var array<string>
128
     */
129
    protected array $notices = [];
130
131
    /**
132
     * Is this extension locally available or only in store
133
     */
134
    protected string $source = self::SOURCE_LOCAL;
135
136
    /**
137
     * Is the update local or in store
138
     */
139
    protected string $updateSource = self::SOURCE_LOCAL;
140
141
    protected bool $allowDisable = true;
142
143
    /**
144
     * @var array<string>
145
     */
146
    protected array $domains = [];
147
148
    protected string $lastUpdateDate;
149
150
    protected string $producerWebsite;
151
152
    protected string $storeUrl;
153
154
    /**
155
     * @param array<string, mixed> $data
156
     *
157
     * @throws \InvalidArgumentException
158
     */
159
    public static function fromArray(array $data): ExtensionStruct
160
    {
161
        if (!isset($data['name'])) {
162
            throw new \InvalidArgumentException('Entry "name" in payload missing');
163
        }
164
165
        if (!isset($data['label'])) {
166
            throw new \InvalidArgumentException('Entry "label" in payload missing');
167
        }
168
169
        if (!isset($data['type'])) {
170
            throw new \InvalidArgumentException('Entry "type" in payload missing');
171
        }
172
173
        return (new self())->assign($data);
174
    }
175
176
    public function getId(): ?int
177
    {
178
        return $this->id;
179
    }
180
181
    public function setId(?int $id): void
182
    {
183
        $this->id = $id;
184
    }
185
186
    public function getLocalId(): ?string
187
    {
188
        return $this->localId;
189
    }
190
191
    public function setLocalId(?string $localId): void
192
    {
193
        $this->localId = $localId;
194
    }
195
196
    public function getName(): string
197
    {
198
        return $this->name;
199
    }
200
201
    public function setName(string $name): void
202
    {
203
        $this->name = $name;
204
    }
205
206
    public function getLabel(): string
207
    {
208
        return $this->label;
209
    }
210
211
    public function setLabel(string $label): void
212
    {
213
        $this->label = $label;
214
    }
215
216
    public function getDescription(): ?string
217
    {
218
        return $this->description;
219
    }
220
221
    public function setDescription(?string $description): void
222
    {
223
        $this->description = $description;
224
    }
225
226
    public function getShortDescription(): ?string
227
    {
228
        return $this->shortDescription;
229
    }
230
231
    public function setShortDescription(?string $shortDescription): void
232
    {
233
        $this->shortDescription = $shortDescription;
234
    }
235
236
    public function getProducerName(): ?string
237
    {
238
        return $this->producerName;
239
    }
240
241
    public function setProducerName(string $producerName): void
242
    {
243
        $this->producerName = $producerName;
244
    }
245
246
    public function getLicense(): ?string
247
    {
248
        return $this->license;
249
    }
250
251
    public function setLicense(string $license): void
252
    {
253
        $this->license = $license;
254
    }
255
256
    public function getVersion(): ?string
257
    {
258
        return $this->version;
259
    }
260
261
    public function setVersion(string $version): void
262
    {
263
        $this->version = $version;
264
    }
265
266
    public function getLatestVersion(): ?string
267
    {
268
        return $this->latestVersion;
269
    }
270
271
    public function setLatestVersion(?string $latestVersion): void
272
    {
273
        $this->latestVersion = $latestVersion;
274
    }
275
276
    public function getPrivacyPolicyLink(): ?string
277
    {
278
        return $this->privacyPolicyLink;
279
    }
280
281
    public function setPrivacyPolicyLink(?string $privacyPolicyLink): void
282
    {
283
        $this->privacyPolicyLink = $privacyPolicyLink;
284
    }
285
286
    public function getVariants(): ?VariantCollection
287
    {
288
        return $this->variants;
289
    }
290
291
    public function setVariants(VariantCollection $variants): void
292
    {
293
        $this->variants = $variants;
294
    }
295
296
    /**
297
     * @return array<string>|null
298
     */
299
    public function getLanguages(): ?array
300
    {
301
        return $this->languages;
302
    }
303
304
    /**
305
     * @param array<string> $languages
306
     */
307
    public function setLanguages(array $languages): void
308
    {
309
        $this->languages = $languages;
310
    }
311
312
    public function getRating(): ?float
313
    {
314
        return $this->rating;
315
    }
316
317
    public function setRating(float $rating): void
318
    {
319
        $this->rating = $rating;
320
    }
321
322
    public function getNumberOfRatings(): int
323
    {
324
        return $this->numberOfRatings;
325
    }
326
327
    public function setNumberOfRatings(int $numberOfRatings): void
328
    {
329
        $this->numberOfRatings = $numberOfRatings;
330
    }
331
332
    public function getFaq(): ?FaqCollection
333
    {
334
        return $this->faq;
335
    }
336
337
    public function setFaq(FaqCollection $faq): void
338
    {
339
        $this->faq = $faq;
340
    }
341
342
    public function getBinaries(): ?BinaryCollection
343
    {
344
        return $this->binaries;
345
    }
346
347
    public function setBinaries(BinaryCollection $binaries): void
348
    {
349
        $this->binaries = $binaries;
350
    }
351
352
    public function getImages(): ?ImageCollection
353
    {
354
        return $this->images;
355
    }
356
357
    public function setImages(ImageCollection $images): void
358
    {
359
        $this->images = $images;
360
    }
361
362
    public function getCategories(): ?StoreCategoryCollection
363
    {
364
        return $this->categories;
365
    }
366
367
    public function setCategories(StoreCategoryCollection $categories): void
368
    {
369
        $this->categories = $categories;
370
    }
371
372
    public function getIcon(): ?string
373
    {
374
        return $this->icon;
375
    }
376
377
    public function setIcon(?string $icon): void
378
    {
379
        $this->icon = $icon;
380
    }
381
382
    public function getIconRaw(): ?string
383
    {
384
        return $this->iconRaw;
385
    }
386
387
    public function setIconRaw(string $iconRaw): void
388
    {
389
        $this->iconRaw = $iconRaw;
390
    }
391
392
    public function getPermissions(): ?PermissionCollection
393
    {
394
        return $this->permissions;
395
    }
396
397
    public function setPermissions(?PermissionCollection $permissions): void
398
    {
399
        $this->permissions = $permissions;
400
    }
401
402
    /**
403
     * @return array<string, PermissionCollection>
404
     */
405
    public function getCategorizedPermissions(): array
406
    {
407
        if ($this->permissions === null) {
408
            return [];
409
        }
410
411
        return $this->permissions->getCategorizedPermissions();
412
    }
413
414
    public function jsonSerialize(): array
415
    {
416
        $vars = get_object_vars($this);
417
        $vars['permissions'] = $this->getCategorizedPermissions();
418
419
        return $vars;
420
    }
421
422
    public function getActive(): bool
423
    {
424
        return $this->active;
425
    }
426
427
    public function setActive(bool $active): void
428
    {
429
        $this->active = $active;
430
    }
431
432
    public function getType(): string
433
    {
434
        return $this->type;
435
    }
436
437
    public function setType(string $type): void
438
    {
439
        $this->type = $type;
440
    }
441
442
    public function isTheme(): bool
443
    {
444
        return $this->isTheme;
445
    }
446
447
    public function setIsTheme(bool $isTheme): void
448
    {
449
        $this->isTheme = $isTheme;
450
    }
451
452
    public function isConfigurable(): bool
453
    {
454
        return $this->configurable;
455
    }
456
457
    public function setConfigurable(bool $configurable): void
458
    {
459
        $this->configurable = $configurable;
460
    }
461
462
    public function getPrivacyPolicyExtension(): ?string
463
    {
464
        return $this->privacyPolicyExtension;
465
    }
466
467
    public function setPrivacyPolicyExtension(?string $privacyPolicyExtension): void
468
    {
469
        $this->privacyPolicyExtension = $privacyPolicyExtension;
470
    }
471
472
    public function getStoreLicense(): ?LicenseStruct
473
    {
474
        return $this->storeLicense;
475
    }
476
477
    public function setStoreLicense(?LicenseStruct $storeLicense): void
478
    {
479
        $this->storeLicense = $storeLicense;
480
    }
481
482
    public function getInstalledAt(): ?\DateTimeInterface
483
    {
484
        return $this->installedAt;
485
    }
486
487
    public function setInstalledAt(?\DateTimeInterface $installedAt): void
488
    {
489
        $this->installedAt = $installedAt;
490
    }
491
492
    /**
493
     * @return array<string>
494
     */
495
    public function getNotices(): array
496
    {
497
        return $this->notices;
498
    }
499
500
    /**
501
     * @param array<string> $notices
502
     */
503
    public function setNotices(array $notices): void
504
    {
505
        $this->notices = $notices;
506
    }
507
508
    public function getSource(): string
509
    {
510
        return $this->source;
511
    }
512
513
    public function setSource(string $source): void
514
    {
515
        $this->source = $source;
516
    }
517
518
    public function getUpdateSource(): string
519
    {
520
        return $this->updateSource;
521
    }
522
523
    public function setUpdateSource(string $updateSource): void
524
    {
525
        $this->updateSource = $updateSource;
526
    }
527
528
    public function getStoreExtension(): ?ExtensionStruct
529
    {
530
        return $this->storeExtension;
531
    }
532
533
    public function setStoreExtension(?ExtensionStruct $storeExtension): void
534
    {
535
        $this->storeExtension = $storeExtension;
536
    }
537
538
    public function getUpdatedAt(): ?\DateTimeInterface
539
    {
540
        return $this->updatedAt;
541
    }
542
543
    public function setUpdatedAt(?\DateTimeInterface $updatedAt): void
544
    {
545
        $this->updatedAt = $updatedAt;
546
    }
547
548
    public function isAllowDisable(): bool
549
    {
550
        return $this->allowDisable;
551
    }
552
553
    public function setAllowDisable(bool $allowDisable): void
554
    {
555
        $this->allowDisable = $allowDisable;
556
    }
557
558
    /**
559
     * @return array<string>
560
     */
561
    public function getDomains(): array
562
    {
563
        return $this->domains;
564
    }
565
566
    /**
567
     * @param array<string> $domains
568
     */
569
    public function setDomains(array $domains): void
570
    {
571
        $this->domains = $domains;
572
    }
573
574
    public function getLastUpdateDate(): string
575
    {
576
        return $this->lastUpdateDate;
577
    }
578
579
    public function setLastUpdateDate(string $lastUpdateDate): void
580
    {
581
        $this->lastUpdateDate = $lastUpdateDate;
582
    }
583
584
    public function getProducerWebsite(): string
585
    {
586
        return $this->producerWebsite;
587
    }
588
589
    public function setProducerWebsite(string $producerWebsite): void
590
    {
591
        $this->producerWebsite = $producerWebsite;
592
    }
593
594
    public function getStoreUrl(): string
595
    {
596
        return $this->storeUrl;
597
    }
598
599
    public function setStoreUrl(string $storeUrl): void
600
    {
601
        $this->storeUrl = $storeUrl;
602
    }
603
}
604