Completed
Push — master ( 2a954a...31dc8b )
by Aimeos
02:47
created

Base   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 213
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

14 Methods

Rating   Name   Duplication   Size   Complexity  
A createManager() 0 4 1
A createCatalogFilter() 0 4 1
A getCatalogPath() 0 4 1
A getCatalogTree() 0 5 1
A aggregateIndex() 0 4 1
A addIndexFilterCategory() 0 4 1
A addIndexFilterText() 0 4 1
A createIndexFilter() 0 4 1
A createIndexFilterCategory() 0 4 1
A createIndexFilterText() 0 4 1
A getIndexItems() 0 4 1
A getProductItems() 0 4 1
A createTextFilter() 0 4 1
A getTextList() 0 4 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2016
6
 * @package Controller
7
 * @subpackage Frontend
8
 */
9
10
11
namespace Aimeos\Controller\Frontend\Catalog\Decorator;
12
13
14
/**
15
 * Base for catalog frontend controller decorators
16
 *
17
 * @package Controller
18
 * @subpackage Frontend
19
 */
20
abstract class Base extends \Aimeos\Controller\Frontend\Common\Decorator\Base
21
{
22
	/**
23
	 * Returns the manager for the given name
24
	 *
25
	 * @param string $name Name of the manager
26
	 * @return \Aimeos\MShop\Common\Manager\Iface Manager object
27
	 */
28
	public function createManager( $name )
29
	{
30
		return $this->getController()->createManager( $name );
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Common\Iface as the method createManager() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
31
	}
32
33
34
	/**
35
	 * Returns the default catalog filter
36
	 *
37
	 * @return \Aimeos\MW\Criteria\Iface Criteria object for filtering
38
	 * @since 2015.08
39
	 */
40
	public function createCatalogFilter()
41
	{
42
		return $this->getController()->createCatalogFilter();
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Common\Iface as the method createCatalogFilter() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
43
	}
44
45
46
47
	/**
48
	 * Returns the list of categries that are in the path to the root node including the one specified by its ID.
49
	 *
50
	 * @param integer $id Category ID to start from, null for root node
51
	 * @param string[] $domains Domain names of items that are associated with the categories and that should be fetched too
52
	 * @return array Associative list of items implementing \Aimeos\MShop\Catalog\Item\Iface with their IDs as keys
53
	 * @since 2015.08
54
	 */
55
	public function getCatalogPath( $id, array $domains = array( 'text', 'media' ) )
56
	{
57
		return $this->getController()->getCatalogPath( $id, $domains );
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Common\Iface as the method getCatalogPath() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
58
	}
59
60
61
	/**
62
	 * Returns the hierarchical catalog tree starting from the given ID.
63
	 *
64
	 * @param integer|null $id Category ID to start from, null for root node
65
	 * @param string[] $domains Domain names of items that are associated with the categories and that should be fetched too
66
	 * @param integer $level Constant from \Aimeos\MW\Tree\Manager\Base for the depth of the returned tree, LEVEL_ONE for
67
	 * 	specific node only, LEVEL_LIST for node and all direct child nodes, LEVEL_TREE for the whole tree
68
	 * @param \Aimeos\MW\Criteria\Iface|null $search Optional criteria object with conditions
69
	 * @return \Aimeos\MShop\Catalog\Item\Iface Catalog node, maybe with children depending on the level constant
70
	 * @since 2015.08
71
	 */
72
	public function getCatalogTree( $id = null, array $domains = array( 'text', 'media' ),
73
		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE, \Aimeos\MW\Criteria\Iface $search = null )
74
	{
75
		return $this->getController()->getCatalogTree( $id, $domains, $level, $search );
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Common\Iface as the method getCatalogTree() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
76
	}
77
78
79
	/**
80
	 * Returns the aggregated count of products from the index for the given key.
81
	 *
82
	 * @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions
83
	 * @param string $key Search key to aggregate for, e.g. "index.attribute.id"
84
	 * @return array Associative list of key values as key and the product count for this key as value
85
	 * @since 2015.08
86
	 */
87
	public function aggregateIndex( \Aimeos\MW\Criteria\Iface $filter, $key )
88
	{
89
		return $this->getController()->aggregateIndex( $filter, $key );
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Common\Iface as the method aggregateIndex() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
90
	}
91
92
93
	/**
94
	 * Returns the given search filter with the conditions attached for filtering by category.
95
	 *
96
	 * @param \Aimeos\MW\Criteria\Iface $search Criteria object used for product search
97
	 * @param string $catid Selected category by the user
98
	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
99
	 * @since 2015.08
100
	 */
101
	public function addIndexFilterCategory( \Aimeos\MW\Criteria\Iface $search, $catid )
102
	{
103
		return $this->getController()->addIndexFilterCategory( $search, $catid );
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Common\Iface as the method addIndexFilterCategory() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
104
	}
105
106
107
	/**
108
	 * Returns the given search filter with the conditions attached for filtering texts.
109
	 *
110
	 * @param \Aimeos\MW\Criteria\Iface $search Criteria object used for product search
111
	 * @param string $input Search string entered by the user
112
	 * @param string $listtype List type of the text associated to the product, usually "default"
113
	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
114
	 * @since 2015.08
115
	 */
116
	public function addIndexFilterText( \Aimeos\MW\Criteria\Iface $search, $input, $listtype = 'default' )
117
	{
118
		return $this->getController()->addIndexFilterText( $search, $input, $listtype );
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Common\Iface as the method addIndexFilterText() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
119
	}
120
121
122
	/**
123
	 * Returns the default index filter.
124
	 *
125
	 * @param string|null $sort Sortation of the product list like "name", "code", "price" and "position", null for no sortation
126
	 * @param string $direction Sort direction of the product list ("+", "-")
127
	 * @param integer $start Position in the list of found products where to begin retrieving the items
128
	 * @param integer $size Number of products that should be returned
129
	 * @param string $listtype Type of the product list, e.g. default, promotion, etc.
130
	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
131
	 * @since 2015.08
132
	 */
133
	public function createIndexFilter( $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default' )
134
	{
135
		return $this->getController()->createIndexFilter( $sort, $direction, $start, $size, $listtype );
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Common\Iface as the method createIndexFilter() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
136
	}
137
138
139
	/**
140
	 * Returns a index filter for the given category ID.
141
	 *
142
	 * @param integer $catid ID of the category to get the product list from
143
	 * @param string $sort Sortation of the product list like "name", "price" and "position"
144
	 * @param string $direction Sort direction of the product list ("asc", "desc")
145
	 * @param integer $start Position in the list of found products where to begin retrieving the items
146
	 * @param integer $size Number of products that should be returned
147
	 * @param string $listtype Type of the product list, e.g. default, promotion, etc.
148
	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
149
	 * @since 2015.08
150
	 */
151
	public function createIndexFilterCategory( $catid, $sort = 'position', $direction = 'asc', $start = 0, $size = 100, $listtype = 'default' )
152
	{
153
		return $this->getController()->createIndexFilter( $catid, $sort, $direction, $start, $size, $listtype );
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Common\Iface as the method createIndexFilter() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
154
	}
155
156
157
	/**
158
	 * Returns the index filter for the given search string.
159
	 *
160
	 * @param string $input Search string entered by the user
161
	 * @param string $sort Sortation of the product list like "name", "price" and "relevance"
162
	 * @param string $direction Sort direction of the product list ("asc", "desc", but not for relevance )
163
	 * @param integer $start Position in the list of found products where to begin retrieving the items
164
	 * @param integer $size Number of products that should be returned
165
	 * @param string $listtype List type of the text associated to the product, usually "default"
166
	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
167
	 * @since 2015.08
168
	 */
169
	public function createIndexFilterText( $input, $sort = 'relevance', $direction = 'asc', $start = 0, $size = 100, $listtype = 'default' )
170
	{
171
		return $this->getController()->createIndexFilter( $input, $sort, $direction, $start, $size, $listtype );
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Common\Iface as the method createIndexFilter() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
172
	}
173
174
175
	/**
176
	 * Returns the products from the index filtered by the given criteria object.
177
	 *
178
	 * @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions
179
	 * @param string[] $domains Domain names of items that are associated with the products and that should be fetched too
180
	 * @param integer &$total Parameter where the total number of found products will be stored in
181
	 * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface
182
	 * @since 2015.08
183
	 */
184
	public function getIndexItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null )
185
	{
186
		return $this->getController()->getIndexItems( $filter, $domains, $total );
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Common\Iface as the method getIndexItems() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
187
	}
188
189
190
	/**
191
	 * Returns the product item for the given ID if it's available
192
	 *
193
	 * @param array $ids List of product IDs
194
	 * @param array $domains Domain names of items that are associated with the products and that should be fetched too
195
	 * @return array List of product items implementing \Aimeos\MShop\Product\Item\Iface
196
	 * @since 2015.08
197
	 */
198
	public function getProductItems( array $ids, array $domains = array( 'media', 'price', 'text' ) )
199
	{
200
		return $this->getController()->getProductItems( $ids, $domains );
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Common\Iface as the method getProductItems() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
201
	}
202
203
204
	/**
205
	 * Returns text filter for the given search string.
206
	 *
207
	 * @param string $input Search string entered by the user
208
	 * @param string|null $sort Sortation of the product list like "name" and "relevance", null for no sortation
209
	 * @param string $direction Sort direction of the product list ("asc", "desc")
210
	 * @param integer $start Position in the list of found products where to begin retrieving the items
211
	 * @param integer $size Number of products that should be returned
212
	 * @param string $listtype List type of the text associated to the product, usually "default"
213
	 * @param string $type Type of the text like "name", "short", "long", etc.
214
	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
215
	 */
216
	public function createTextFilter( $input, $sort = null, $direction = 'desc', $start = 0, $size = 25, $listtype = 'default', $type = 'name' )
217
	{
218
		return $this->getController()->createTextFilter( $input, $sort, $direction, $start, $size, $listtype, $type );
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Common\Iface as the method createTextFilter() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
219
	}
220
221
222
	/**
223
	 * Returns an list of product text strings matched by the filter.
224
	 *
225
	 * @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions
226
	 * @return array Associative list of the product ID as key and the product text as value
227
	 */
228
	public function getTextList( \Aimeos\MW\Criteria\Iface $filter )
229
	{
230
		return $this->getController()->getTextList( $filter );
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Common\Iface as the method getTextList() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
231
	}
232
}
233