Code Duplication    Length = 13-14 lines in 3 locations

lib/Db/OtoConfirmationMapper.php 1 location

@@ 32-45 (lines=14) @@
29
        return $this->findEntities($sql, [$userId]);
30
	}
31
	
32
	public function canConfirm($otoLayerId){
33
		$sql = 'SELECT COUNT(*) as `count` FROM `*PREFIX*calendar_oto_confirmations` AS `t1` ' .
34
		'INNER JOIN `*PREFIX*calendar_oto_layers` as `t2` ON `t1`.`oto_layer_id` = `t2`.`oto_layer_id` ' .
35
		'WHERE `t2`.`oto_layer_id` = ?';
36
		$stmt = $this->execute($sql, [$otoLayerId]);
37
38
        $row = $stmt->fetch();
39
        $stmt->closeCursor();
40
        if( $row['count'] > 0 ){
41
			return false;
42
		}else{
43
			return true;
44
		}
45
	}
46
	//deletes all confirmations where otoLayerId = $otoLayerId
47
	public function deleteConfirmationsByOtoLayer($otoLayerId){
48
		$sql = 'DELETE FROM `*PREFIX*calendar_oto_confirmations` WHERE `oto_layer_id` = ?';

lib/Db/OtoLayerMapper.php 2 locations

@@ 43-55 (lines=13) @@
40
        return $this->findEntities($sql, [$userId]);
41
    }
42
	
43
	public function passwordCheck($otoLayerId, $password){
44
		$sql = 'SELECT COUNT(*) AS `count` FROM `*PREFIX*calendar_oto_layers` ' .
45
            'WHERE `oto_layer_id` = ? AND `password` = ?';
46
        $stmt = $this->execute($sql, [$otoLayerId,$password]);
47
48
        $row = $stmt->fetch();
49
        $stmt->closeCursor();
50
        if( $row['count'] > 0 ){
51
			return true;
52
		}else{
53
			return false;
54
		}
55
	}
56
	//deletes all layers where otoLayerId = $otoLayerId
57
	public function deleteLayer($otoLayerId){
58
		$sql = 'DELETE FROM `*PREFIX*calendar_oto_layers` WHERE `oto_layer_id` = ?';
@@ 64-76 (lines=13) @@
61
		$stmt -> execute();
62
	}
63
	//checks if a calendar layer is being used for scheduling
64
	public function isOtoLayer($sourceId){
65
		$sql = 'SELECT COUNT(*) AS `count` FROM `*PREFIX*calendar_oto_layers` ' .
66
            'WHERE `source_id` = ?';
67
        $stmt = $this->execute($sql, [$sourceId]);
68
69
        $row = $stmt->fetch();
70
        $stmt->closeCursor();
71
        if( $row['count'] > 0 ){
72
			return true;
73
		}else{
74
			return false;
75
		}
76
	}
77
	//deletes all layers with the given sourceId
78
	public function deleteBySourceId($sourceId,$userId){
79
		$sql = 'DELETE FROM `*PREFIX*calendar_oto_layers` WHERE `source_id` = ? AND `user_id` = ?';