helper::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 9
dl 0
loc 13
ccs 0
cts 10
cp 0
crap 2
rs 9.9666

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: lucifer
5
 * Date: 13.2.2017 г.
6
 * Time: 17:18
7
 */
8
9
namespace anavaro\pmsearch;
10
11
12
class helper
13
{
14
	public function __construct(\phpbb\extension\manager $ext_manager, \phpbb\auth\auth $auth, \phpbb\config\config $config,
0 ignored issues
show
Bug introduced by
The type phpbb\auth\auth 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...
Bug introduced by
The type phpbb\extension\manager 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...
Bug introduced by
The type phpbb\config\config 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...
15
		\phpbb\db\driver\driver_interface $db, \phpbb\user $user, \phpbb\language\language $language, \phpbb\event\dispatcher $dispatcher,
0 ignored issues
show
Bug introduced by
The type phpbb\language\language 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...
Bug introduced by
The type phpbb\user 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...
Bug introduced by
The type phpbb\event\dispatcher 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...
Bug introduced by
The type phpbb\db\driver\driver_interface 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
		$phpbb_root_path, $phpEx)
17
	{
18
		$this->ext_manager = $ext_manager;
0 ignored issues
show
Bug Best Practice introduced by
The property ext_manager does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
19
		$this->auth = $auth;
0 ignored issues
show
Bug Best Practice introduced by
The property auth does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
20
		$this->config = $config;
0 ignored issues
show
Bug Best Practice introduced by
The property config does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
21
		$this->db = $db;
0 ignored issues
show
Bug Best Practice introduced by
The property db does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
22
		$this->user = $user;
0 ignored issues
show
Bug Best Practice introduced by
The property user does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
23
		$this->lang = $language;
0 ignored issues
show
Bug Best Practice introduced by
The property lang does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
24
		$this->dispatcher = $dispatcher;
0 ignored issues
show
Bug Best Practice introduced by
The property dispatcher does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
25
		$this->root_path = $phpbb_root_path;
0 ignored issues
show
Bug Best Practice introduced by
The property root_path does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
26
		$this->php_ext = $phpEx;
0 ignored issues
show
Bug Best Practice introduced by
The property php_ext does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
27
	}
28
29
	public function get_search_types()
30
	{
31
		$finder = $this->ext_manager->get_finder();
32
33
		return $finder
34
			->extension_suffix('_backend1')
35
			->extension_directory('')
36
			->core_path('ext/anavaro/pmsearch/search/')
37
			->get_classes();
38
	}
39
40
	public function init_search($type, &$search, &$error)
41
	{
42
		if (!class_exists($type) || !method_exists($type, 'keyword_search'))
43
		{
44
			$error = $this->lang->lang('NO_SUCH_SEARCH_MODULE');
45
			return $error;
46
		}
47
48
		$error = false;
49
		$search = new $type($error, $this->root_path, $this->php_ext, $this->auth, $this->config, $this->db, $this->user, $this->dispatcher);
50
51
		return $error;
52
	}
53
}