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

StorePage::open()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 1
nc 1
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