Passed
Push — v3 ( c4eb1a...fabe49 )
by Andrew
33:23 queued 19:58
created

CampaignBehavior   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 12
c 1
b 0
f 0
dl 0
loc 29
ccs 0
cts 15
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getSiteSettings() 0 16 2
1
<?php
2
/**
3
 * SEOmatic plugin for Craft CMS 3.x
4
 *
5
 * A turnkey SEO implementation for Craft CMS that is comprehensive, powerful,
6
 * and flexible
7
 *
8
 * @link      https://nystudio107.com
9
 * @copyright Copyright (c) 2017 nystudio107
10
 */
11
12
namespace nystudio107\seomatic\integrations\campaign\behaviors;
13
14
use Craft;
15
use craft\models\Section_SiteSettings;
16
use putyourlightson\campaign\models\CampaignTypeModel;
0 ignored issues
show
Bug introduced by
The type putyourlightson\campaign\models\CampaignTypeModel 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...
17
use yii\base\Behavior;
18
19
/**
20
 * @mixin CampaignTypeModel
21
 *
22
 * @author    nystudio107.com
23
 * @package   SEOmatic
24
 * @since     4.0.32
25
 */
26
class CampaignBehavior extends Behavior
27
{
28
    // Public Properties
29
    // =========================================================================
30
31
    // Public Methods
32
    // =========================================================================
33
34
    /**
35
     * Returns the product types's site-specific settings.
36
     *
37
     * @return Section_SiteSettings[]
38
     */
39
    public function getSiteSettings(): array
40
    {
41
        $siteSettings = [];
42
        $sites = Craft::$app->getSites()->getAllSites();
43
        foreach ($sites as $site) {
44
            $siteSettings[$site->id] = new Section_SiteSettings([
45
                'id' => $site->id,
46
                'sectionId' => $this->owner->id,
47
                'siteId' => $site->id,
48
                'hasUrls' => !empty($this->owner->uriFormat),
49
                'uriFormat' => $this->owner->uriFormat,
50
                'template' => $this->owner->htmlTemplate,
51
            ]);
52
        }
53
54
        return $siteSettings;
55
    }
56
57
}
58