CacheManager::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * ownCloud - passman
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Sander Brand <[email protected]>
9
 * @copyright Sander Brand 2014
10
 */
11
namespace OCA\Maps\Db;
12
13
use OCP\IDBConnection;
14
15
class CacheManager {
16
	private $db;
17 1
	public function __construct(IDBConnection $db) {
18 1
		$this -> db = $db;
19 1
	}
20
21
	/**
22
	 * List items in a folder
23
	 */
24
	
25
	
26 View Code Duplication
	public function insert($hash,$raw){
0 ignored issues
show
Duplication introduced by
This method 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...
27
		$serialized = serialize($raw);
28
		$sql = "INSERT INTO `*PREFIX*maps_adress_cache` (adres_hash,serialized) VALUES(?,?)";
29
		$query = $this -> db -> prepare($sql);
30
		$query -> bindParam(1, $hash, \PDO::PARAM_STR);
31
		$query -> bindParam(2, $serialized, \PDO::PARAM_STR);
32
		$result = $query -> execute();
0 ignored issues
show
Unused Code introduced by
$result 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...
33
	}
34
	
35 View Code Duplication
	public function check($hash){
0 ignored issues
show
Duplication introduced by
This method 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...
36
		$sql = 'SELECT * from `*PREFIX*maps_adress_cache` where adres_hash=?';
37
		$query = $this -> db -> prepare($sql);
38
		$query -> bindParam(1, $hash, \PDO::PARAM_STR);
39
		$query -> execute();
40
		$result = $query->fetch();
41
		return unserialize($result['serialized']);
42
	} 
43
}
44