CatalogController::homeAction()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 10
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
/**
4
 * @license MIT, http://opensource.org/licenses/MIT
5
 * @copyright Aimeos (aimeos.org), 2015-2016
6
 * @package laravel
7
 * @subpackage Controller
8
 */
9
10
11
namespace Aimeos\Shop\Controller;
12
13
use Aimeos\Shop\Facades\Shop;
14
use Illuminate\Routing\Controller;
15
use Illuminate\Support\Facades\Response;
16
17
18
/**
19
 * Aimeos controller for catalog related functionality.
20
 *
21
 * @package laravel
22
 * @subpackage Controller
23
 */
24
class CatalogController extends Controller
25
{
26
	/**
27
	 * Returns the view for the XHR response with the counts for the facetted search.
28
	 *
29
	 * @return \Illuminate\Http\Response Response object with output and headers
30
	 */
31
	public function countAction()
32
	{
33
		foreach( app( 'config' )->get( 'shop.page.catalog-count' ) as $name )
34
		{
35
			$params['aiheader'][$name] = Shop::get( $name )->getHeader();
0 ignored issues
show
Unused Code introduced by Andreas
The call to Aimeos\Shop\Facades\Shop::get() has too many arguments starting with $name. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
			$params['aiheader'][$name] = Shop::/** @scrutinizer ignore-call */ get( $name )->getHeader();

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
36
			$params['aibody'][$name] = Shop::get( $name )->getBody();
37
		}
38
39
		return Response::view( Shop::template( 'catalog.count' ), $params )
0 ignored issues
show
Comprehensibility Best Practice introduced by Andreas
The variable $params seems to be defined by a foreach iteration on line 33. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
Bug introduced by Andreas
The method template() does not exist on Aimeos\Shop\Facades\Shop. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
		return Response::view( Shop::/** @scrutinizer ignore-call */ template( 'catalog.count' ), $params )
Loading history...
40
			->header( 'Content-Type', 'application/javascript' )
41
			->header( 'Cache-Control', 'public, max-age=300' );
42
	}
43
44
45
	/**
46
	 * Returns the html for the catalog detail page.
47
	 *
48
	 * @return \Illuminate\Http\Response Response object with output and headers
49
	 */
50
	public function detailAction()
51
	{
52
		foreach( app( 'config' )->get( 'shop.page.catalog-detail' ) as $name )
53
		{
54
			$params['aiheader'][$name] = Shop::get( $name )->getHeader();
0 ignored issues
show
Unused Code introduced by Andreas
The call to Aimeos\Shop\Facades\Shop::get() has too many arguments starting with $name. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

54
			$params['aiheader'][$name] = Shop::/** @scrutinizer ignore-call */ get( $name )->getHeader();

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
55
			$params['aibody'][$name] = Shop::get( $name )->getBody();
56
		}
57
58
		return Response::view( Shop::template( 'catalog.detail' ), $params )
0 ignored issues
show
Comprehensibility Best Practice introduced by Andreas
The variable $params seems to be defined by a foreach iteration on line 52. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
59
			->header( 'Cache-Control', 'private, max-age=10' );
60
	}
61
62
63
	/**
64
	 * Returns the html for the catalog home page.
65
	 *
66
	 * @return \Illuminate\Http\Response Response object with output and headers
67
	 */
68
	public function homeAction()
69
	{
70
		foreach( app( 'config' )->get( 'shop.page.catalog-home' ) as $name )
71
		{
72
			$params['aiheader'][$name] = Shop::get( $name )->getHeader();
0 ignored issues
show
Unused Code introduced by Andreas
The call to Aimeos\Shop\Facades\Shop::get() has too many arguments starting with $name. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

72
			$params['aiheader'][$name] = Shop::/** @scrutinizer ignore-call */ get( $name )->getHeader();

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
73
			$params['aibody'][$name] = Shop::get( $name )->getBody();
74
		}
75
76
		return Response::view( Shop::template( 'catalog.home' ), $params )
0 ignored issues
show
Comprehensibility Best Practice introduced by Andreas
The variable $params seems to be defined by a foreach iteration on line 70. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
77
			->header( 'Cache-Control', 'private, max-age=10' );
78
	}
79
80
81
	/**
82
	 * Returns the html for the catalog list page.
83
	 *
84
	 * @return \Illuminate\Http\Response Response object with output and headers
85
	 */
86
	public function listAction()
87
	{
88
		foreach( app( 'config' )->get( 'shop.page.catalog-list' ) as $name )
89
		{
90
			$params['aiheader'][$name] = Shop::get( $name )->getHeader();
0 ignored issues
show
Unused Code introduced by Andreas
The call to Aimeos\Shop\Facades\Shop::get() has too many arguments starting with $name. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

90
			$params['aiheader'][$name] = Shop::/** @scrutinizer ignore-call */ get( $name )->getHeader();

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
91
			$params['aibody'][$name] = Shop::get( $name )->getBody();
92
		}
93
94
		return Response::view( Shop::template( 'catalog.list' ), $params )
0 ignored issues
show
Comprehensibility Best Practice introduced by Andreas
The variable $params seems to be defined by a foreach iteration on line 88. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
95
			->header( 'Cache-Control', 'private, max-age=10' );
96
	}
97
98
99
	/**
100
	 * Returns the html for the catalog session page.
101
	 *
102
	 * @return \Illuminate\Http\Response Response object with output and headers
103
	 */
104
	public function sessionAction()
105
	{
106
		foreach( app( 'config' )->get( 'shop.page.catalog-session' ) as $name )
107
		{
108
			$params['aiheader'][$name] = Shop::get( $name )->getHeader();
0 ignored issues
show
Unused Code introduced by Andreas
The call to Aimeos\Shop\Facades\Shop::get() has too many arguments starting with $name. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

108
			$params['aiheader'][$name] = Shop::/** @scrutinizer ignore-call */ get( $name )->getHeader();

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
109
			$params['aibody'][$name] = Shop::get( $name )->getBody();
110
		}
111
112
		return Response::view( Shop::template( 'catalog.session' ), $params )
0 ignored issues
show
Comprehensibility Best Practice introduced by Andreas
The variable $params seems to be defined by a foreach iteration on line 106. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
113
			->header( 'Cache-Control', 'no-cache' );
114
	}
115
116
117
	/**
118
	 * Returns the html body part for the catalog stock page.
119
	 *
120
	 * @return \Illuminate\Http\Response Response object with output and headers
121
	 */
122
	public function stockAction()
123
	{
124
		foreach( app( 'config' )->get( 'shop.page.catalog-stock' ) as $name )
125
		{
126
			$params['aiheader'][$name] = Shop::get( $name )->getHeader();
0 ignored issues
show
Unused Code introduced by Andreas
The call to Aimeos\Shop\Facades\Shop::get() has too many arguments starting with $name. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

126
			$params['aiheader'][$name] = Shop::/** @scrutinizer ignore-call */ get( $name )->getHeader();

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
127
			$params['aibody'][$name] = Shop::get( $name )->getBody();
128
		}
129
130
		return Response::view( Shop::template( 'catalog.stock' ), $params )
0 ignored issues
show
Comprehensibility Best Practice introduced by Scrutinizer Auto-Fixer
The variable $params seems to be defined by a foreach iteration on line 124. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
131
			->header( 'Content-Type', 'application/javascript' )
132
			->header( 'Cache-Control', 'public, max-age=30' );
133
	}
134
135
136
	/**
137
	 * Returns the view for the XHR response with the product information for the search suggestion.
138
	 *
139
	 * @return \Illuminate\Http\Response Response object with output and headers
140
	 */
141
	public function suggestAction()
142
	{
143
		foreach( app( 'config' )->get( 'shop.page.catalog-suggest' ) as $name )
144
		{
145
			$params['aiheader'][$name] = Shop::get( $name )->getHeader();
0 ignored issues
show
Unused Code introduced by Andreas
The call to Aimeos\Shop\Facades\Shop::get() has too many arguments starting with $name. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

145
			$params['aiheader'][$name] = Shop::/** @scrutinizer ignore-call */ get( $name )->getHeader();

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
146
			$params['aibody'][$name] = Shop::get( $name )->getBody();
147
		}
148
149
		return Response::view( Shop::template( 'catalog.suggest' ), $params )
0 ignored issues
show
Comprehensibility Best Practice introduced by Andreas
The variable $params seems to be defined by a foreach iteration on line 143. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
150
			->header( 'Cache-Control', 'private, max-age=300' )
151
			->header( 'Content-Type', 'application/json' );
152
	}
153
154
155
	/**
156
	 * Returns the html for the catalog tree page.
157
	 *
158
	 * @return \Illuminate\Http\Response Response object with output and headers
159
	 */
160
	public function treeAction()
161
	{
162
		foreach( app( 'config' )->get( 'shop.page.catalog-tree' ) as $name )
163
		{
164
			$params['aiheader'][$name] = Shop::get( $name )->getHeader();
0 ignored issues
show
Unused Code introduced by Andreas
The call to Aimeos\Shop\Facades\Shop::get() has too many arguments starting with $name. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

164
			$params['aiheader'][$name] = Shop::/** @scrutinizer ignore-call */ get( $name )->getHeader();

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
165
			$params['aibody'][$name] = Shop::get( $name )->getBody();
166
		}
167
168
		return Response::view( Shop::template( 'catalog.tree' ), $params )
0 ignored issues
show
Comprehensibility Best Practice introduced by Andreas
The variable $params seems to be defined by a foreach iteration on line 162. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
169
			->header( 'Cache-Control', 'private, max-age=10' );
170
	}
171
}