Ubb   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A Url2Link() 0 16 2
A Url2Name() 0 9 1
1
<?php
2
/**
3
 * Obsoleted.
4
 *
5
* @package      MaGod
6
* @copyright    Copyright 2004, Fwolf
7
* @author       Fwolf <[email protected]>
8
*/
9
10
require_once('MaGod/MaGod.php');
11
12
/**
13
* Ubb类
14
* 完成对UBB代码的转换
15
*
16
* @package    MaGod
17
* @copyright  Copyright 2004, Fwolf
18
* @author     Fwolf <[email protected]>
19
* @since      2004-02-18 22:10:55
20
* @access     public
21
* @version    $Id$
22
*/
23
24
class Ubb
25
{
26
27
	/**
28
	 * 从UBB的URL格式中取得链接地址
29
	 *
30
	 * @param	string	$url
31
	 * @access	public
32
	 * @return string
33
	 */
34
	function Url2Link($url)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
35
	{
36
		$str = '';
0 ignored issues
show
Unused Code introduced by
$str is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
37
		//格式一:[url=地址]名称[/url]
38
		$patterns = '/\[url=(\S+)\](\S+)\[\/url\]/i';
39
		$replace = '\\1';
40
		$str = preg_replace( $patterns, $replace, $url );
41
		if ( empty($str) )
42
		{
43
			//格式二:[url]地址[/url]
44
		    $patterns = '/\[url\](\S+)\[\/url\]/i';
45
			$replace = '\\1';
46
			$str = preg_replace( $patterns, $replace, $url );
47
		}
48
		return($str);
49
	} // end of function Url2Link
50
51
52
	/**
53
	 * 从UBB的URL格式中取得链接名称
54
	 *
55
	 * @param	string	$url
56
	 * @access	public
57
	 * @return string
58
	 */
59
	function Url2Name($url)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
60
	{
61
		$str = '';
0 ignored issues
show
Unused Code introduced by
$str is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
62
		//格式一:[url=地址]名称[/url]
63
		$patterns = '/\[url=(\S+)\](\S+)\[\/url\]/i';
64
		$replace = '\\2';
65
		$str = preg_replace( $patterns, $replace, $url );
66
		return($str);
67
	} // end of function Url2Name
68
69
} // end of class Ubb
70
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
71