Passed
Push — develop ( d144ab...2bd6f3 )
by Andrew
10:24
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
 * Similar plugin for Craft CMS 3.x
4
 *
5
 * Similar for Craft lets you find elements, Entries, Categories, Commerce Products, etc, that are similar, based on... other related elements.
6
 *
7
 * @link      https://nystudio107.com/
8
 * @copyright Copyright (c) 2018 nystudio107.com
9
 */
10
11
namespace nystudio107\seomatic\integrations\campaign\behaviors;
12
13
use Craft;
14
use craft\models\Section_SiteSettings;
15
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...
16
use yii\base\Behavior;
17
18
/**
19
 * @mixin CampaignTypeModel
20
 *
21
 * @author    nystudio107.com
22
 * @package   SEOmatic
23
 * @since     4.0.32
24
 */
25
class CampaignBehavior extends Behavior
26
{
27
    // Public Properties
28
    // =========================================================================
29
30
    // Public Methods
31
    // =========================================================================
32
33
    /**
34
     * Returns the product types's site-specific settings.
35
     *
36
     * @return Section_SiteSettings[]
37
     */
38
    public function getSiteSettings(): array
39
    {
40
        $siteSettings = [];
41
        $sites = Craft::$app->getSites()->getAllSites();
42
        foreach ($sites as $site) {
43
            $siteSettings[$site->id] = new Section_SiteSettings([
44
                'id' => $site->id,
45
                'sectionId' => $this->owner->id,
46
                'siteId' => $site->id,
47
                'hasUrls' => !empty($this->owner->uriFormat),
48
                'uriFormat' => $this->owner->uriFormat,
49
                'template' => $this->owner->htmlTemplate,
50
            ]);
51
        }
52
53
        return $siteSettings;
54
    }
55
56
}
57