Completed
Push — 3.2.x ( 01dc0a...dfb6c5 )
by Erwan
03:44
created

cat_description::get_table_name()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
*
4
* phpBB Directory extension for the phpBB Forum Software package.
5
*
6
* @copyright (c) 2015 phpBB Limited <https://www.phpbb.com>
7
* @license GNU General Public License, version 2 (GPL-2.0)
8
*
9
*/
10
11
namespace ernadoo\phpbbdirectory\textreparser\plugins;
12
13 View Code Duplication
class cat_description extends \phpbb\textreparser\row_based_plugin
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
{
15
	/**
16
	* {@inheritdoc}
17
	*/
18
	public function get_columns()
19
	{
20
		return array(
21
			'id'         => 'cat_id',
22
			'text'       => 'cat_desc',
23
			'bbcode_uid' => 'cat_desc_uid',
24
			'options'    => 'cat_desc_options',
25
		);
26
	}
27
28
	/**
29
	* {@inheritdoc}
30
	*/
31
	protected function get_records_by_range_query($min_id, $max_id)
32
	{
33
		$columns = $this->get_columns();
34
		$fields  = array();
35
		foreach ($columns as $field_name => $column_name)
36
		{
37
			if ($column_name === $field_name)
38
			{
39
				$fields[] = $column_name;
40
			}
41
			else
42
			{
43
				$fields[] = $column_name . ' AS ' . $field_name;
44
			}
45
		}
46
47
		$sql = 'SELECT ' . implode(', ', $fields) . '
48
			FROM ' . $this->table . '
49
			WHERE ' . $columns['id'] . ' BETWEEN ' . $min_id . ' AND ' . $max_id . '
50
				AND ' . $columns['text'] . ' <> ""';
51
52
		return $sql;
53
	}
54
}
55