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

link_description::get_columns()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 9
Ratio 100 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 9
loc 9
rs 9.6666
cc 1
eloc 6
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 link_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'         => 'link_id',
22
			'text'       => 'link_description',
23
			'bbcode_uid' => 'link_uid',
24
			'options'    => 'link_flags',
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