GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

release_0_0_13   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 66
Duplicated Lines 10.61 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 7
loc 66
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A effectively_installed() 0 4 1
A depends_on() 0 6 1
A update_schema() 0 10 1
A revert_schema() 0 10 1
A update_data() 7 7 1
A calculate_lowercase_tags() 0 19 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
*
4
* @package phpBB Extension - RH Topic Tags
5
* @copyright (c) 2014 Robet Heim
6
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7
*
8
*/
9
10
namespace robertheim\topictags\migrations;
11
12
use robertheim\topictags\prefixes;
13
use robertheim\topictags\tables;
14
15
class release_0_0_13 extends \phpbb\db\migration\migration
16
{
17
	protected $version = '0.0.13-b1';
18
19
	public function effectively_installed()
20
	{
21
		return version_compare($this->config[prefixes::CONFIG.'_version'], $this->version, '>=');
22
	}
23
24
	public static function depends_on()
25
	{
26
		return array(
27
			'\robertheim\topictags\migrations\release_0_0_12',
28
		);
29
	}
30
31
	public function update_schema()
32
	{
33
		return array(
34
			'add_columns'	=> array(
35
				$this->table_prefix . tables::TAGS	=> array(
36
					'tag_lowercase'	=> array('VCHAR:30', ''),
37
				),
38
			),
39
		);
40
	}
41
42
	public function revert_schema()
43
	{
44
		return array(
45
			'drop_columns'	=> array(
46
				$this->table_prefix . tables::TAGS	=> array(
47
					'tag_lowercase',
48
				),
49
			),
50
		);
51
	}
52
53 View Code Duplication
	public function update_data()
54
	{
55
		return array(
56
			array('custom', array(array($this, 'calculate_lowercase_tags'))),
57
			array('config.update', array(prefixes::CONFIG.'_version', $this->version)),
58
		);
59
	}
60
61
	public function calculate_lowercase_tags()
62
	{
63
		$sql = 'SELECT id, tag
64
			FROM ' . $this->table_prefix . tables::TAGS;
65
		$result = $this->db->sql_query($sql);
66
67
		while ($row = $this->db->sql_fetchrow($result))
68
		{
69
			$sql_ary = array(
70
				'tag_lowercase' =>utf8_strtolower($row['tag']),
71
			);
72
			$sql = 'UPDATE ' . $this->table_prefix . tables::TAGS . '
73
				SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
74
				WHERE id = ' . $row['id'];
75
			$this->db->sql_query($sql);
76
		}
77
78
		$this->db->sql_freeresult($result);
79
	}
80
}
81