Failed Conditions
Pull Request — develop (#22)
by Carlo
06:44
created

StorePage   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 1
cbo 0
dl 0
loc 30
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
open() 0 1 ?
A openStorePage() 0 5 1
A setPageObjectPath() 0 6 3
1
<?php
2
namespace Magefix\Plugin;
3
4
/**
5
 * Class StorePage
6
 * @package Magefix\Plugin
7
 * @author  Carlo Tasca <[email protected]>
8
 */
9
trait StorePage
10
{
11
    /**
12
     * @param array $urlParameters
13
     * @return mixed
14
     */
15
    public abstract function open(array $urlParameters = array());
16
17
    /**
18
     * @param string $toBeReplaced
19
     * @param string $replace
20
     * @param array $urlParameters
21
     */
22
    public function openStorePage($toBeReplaced = '', $replace = '', array $urlParameters = [])
23
    {
24
        $this->setPageObjectPath($toBeReplaced, $replace);
25
        $this->open($urlParameters);
26
    }
27
28
    /**
29
     * @param string $toBeReplaced
30
     * @param string $replace
31
     */
32
    public function setPageObjectPath($toBeReplaced, $replace)
33
    {
34
        if (!empty($toBeReplaced) && !empty($replace)) {
35
            $this->path = str_replace($toBeReplaced, $replace, $this->path);
1 ignored issue
show
Bug introduced by
The property path does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
36
        }
37
    }
38
}
39