RealEstateTools::extract_zipcode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
if ( ! class_exists( 'RealEstateTools' ) ) {
4
5
	/**
6
	 * RealEstateTools class.
7
	 */
8
	class RealEstateTools {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
9
10
		/**
11
		 * __construct function.
12
		 *
13
		 * @access public
14
		 * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
15
		 */
16
		public function __construct() {
17
18
		}
19
20
		/**
21
		 * extract_zipcode function.
22
		 *
23
		 * @access public
24
		 * @param mixed $address
25
		 * @return void
26
		 */
27
		public function extract_zipcode( $address ) {
28
			$zipcode = preg_match("/\b[A-Z]{2}\s+\d{5}(-\d{4})?\b/", $address, $matches);
0 ignored issues
show
Unused Code introduced by
$zipcode 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...
29
			return $matches[0];
30
		}
31
32
		/**
33
		 * extract_bed_count function.
34
		 *
35
		 * @access public
36
		 * @param mixed $text
37
		 * @return void
38
		 */
39
		public function extract_bed_count( $text ) {
40
    		$beds = preg_match("/\d (beds|Beds|Bedrooms)/", $text, $matches);
0 ignored issues
show
Unused Code introduced by
$beds 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...
41
			$beds_text = $matches[0];
42
			return $int = filter_var($beds_text, FILTER_SANITIZE_NUMBER_INT);
0 ignored issues
show
Unused Code introduced by
$int 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...
43
		}
44
45
		/**
46
		 * extract_bath_count function.
47
		 *
48
		 * @access public
49
		 * @param mixed $text
50
		 * @return void
51
		 */
52
		public function extract_bath_count( $text ) {
53
    		$baths = preg_match("/\d (bath|Baths|Bathrooms)/", $text, $matches);
0 ignored issues
show
Unused Code introduced by
$baths 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...
54
			$baths_text = $matches[0];
0 ignored issues
show
Unused Code introduced by
$baths_text 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...
55
			return $int = filter_var($beds_text, FILTER_SANITIZE_NUMBER_INT);
0 ignored issues
show
Bug introduced by
The variable $beds_text does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Unused Code introduced by
$int 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...
56
		}
57
58
		/**
59
		 * validate_usa_zipcode function.
60
		 *
61
		 * @access public
62
		 * @param mixed $zip_code
63
		 * @return void
64
		 */
65
		public function validate_usa_zipcode( $zip_code ) {
66
			if ( preg_match("/^([0-9]{5})(-[0-9]{4})?$/i", $zip_code) )
67
				return true;
68
			else
69
				return false;
70
		}
71
72
73
		/**
74
		 * is_valid_latitude function.
75
		 *
76
		 * @access public
77
		 * @param mixed $latitude
78
		 * @return void
79
		 */
80
		public function is_valid_latitude($latitude) {
81
			if ( preg_match("/^-?([1-8]?[1-9]|[1-9]0)\.{1}\d{1,6}$/", $latitude) ) {
82
				return true;
83
			} else {
84
				return false;
85
			}
86
		}
87
88
89
		/**
90
		 * is_valid_longitude function.
91
		 *
92
		 * @access public
93
		 * @param mixed $longitude
94
		 * @return void
95
		 */
96
		public function is_valid_longitude($longitude) {
97
			if (preg_match("/^-?([1]?[1-7][1-9]|[1]?[1-8][0]|[1-9]?[0-9])\.{1}\d{1,6}$/",
98
					$longitude)) {
99
				return true;
100
			} else {
101
				return false;
102
			}
103
		}
104
105
106
	}
107
}
108