Passed
Pull Request — master (#487)
by René
04:26
created

NotificationMapper::findAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
rs 10
ccs 0
cts 3
cp 0
cc 1
eloc 2
nc 1
nop 2
crap 2
1
<?php
2
/**
3
 * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <[email protected]>
4
 *
5
 * @author Vinzenz Rosenkranz <[email protected]>
6
 *
7
 * @license GNU AGPL version 3 or any later version
8
 *
9
 *  This program is free software: you can redistribute it and/or modify
10
 *  it under the terms of the GNU Affero General Public License as
11
 *  published by the Free Software Foundation, either version 3 of the
12
 *  License, or (at your option) any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU Affero General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU Affero General Public License
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 */
23
24
namespace OCA\Polls\Db;
25
26
use OCP\AppFramework\Db\Mapper;
27
use OCP\IDBConnection;
28
29
class NotificationMapper extends Mapper {
0 ignored issues
show
Deprecated Code introduced by
The class OCP\AppFramework\Db\Mapper has been deprecated: 14.0.0 Move over to QBMapper ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

29
class NotificationMapper extends /** @scrutinizer ignore-deprecated */ Mapper {
Loading history...
30
31 3
	public function __construct(IDBConnection $db) {
32 3
		parent::__construct($db, 'polls_notif', '\OCA\Polls\Db\Notification');
0 ignored issues
show
Deprecated Code introduced by
The function OCP\AppFramework\Db\Mapper::__construct() has been deprecated: 14.0.0 Move over to QBMapper ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

32
		/** @scrutinizer ignore-deprecated */ parent::__construct($db, 'polls_notif', '\OCA\Polls\Db\Notification');

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
33 3
	}
34
35
	/**
36
	 * @param int $id
37
	 * @throws \OCP\AppFramework\Db\DoesNotExistException if not found
38
	 * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
39
	 * @return Notification
40
	 */
41
	public function find($id) {
42
		$sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE id = ?';
0 ignored issues
show
Deprecated Code introduced by
The function OCP\AppFramework\Db\Mapper::getTableName() has been deprecated: 14.0.0 Move over to QBMapper ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

42
		$sql = 'SELECT * FROM ' . /** @scrutinizer ignore-deprecated */ $this->getTableName() . ' WHERE id = ?';

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
43
		return $this->findEntity($sql, [$id]);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\AppFramework\Db\Mapper::findEntity() has been deprecated: 14.0.0 Move over to QBMapper ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

43
		return /** @scrutinizer ignore-deprecated */ $this->findEntity($sql, [$id]);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
44
	}
45
46
	/**
47
	 * @param string $userId
48
	 * @param string $from
49
	 * @param string $until
50
	 * @param int $limit
51
	 * @param int $offset
52
	 * @return Notification[]
53
	 */
54
	public function findBetween($userId, $from, $until, $limit = null, $offset = null) {
55
		$sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE userId = ? AND timestamp BETWEEN ? AND ?';
0 ignored issues
show
Deprecated Code introduced by
The function OCP\AppFramework\Db\Mapper::getTableName() has been deprecated: 14.0.0 Move over to QBMapper ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

55
		$sql = 'SELECT * FROM ' . /** @scrutinizer ignore-deprecated */ $this->getTableName() . ' WHERE userId = ? AND timestamp BETWEEN ? AND ?';

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
56
		return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\AppFramework\Db\Mapper::findEntities() has been deprecated: 14.0.0 Move over to QBMapper ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

56
		return /** @scrutinizer ignore-deprecated */ $this->findEntities($sql, [$userId, $from, $until], $limit, $offset);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
57
	}
58
59
	/**
60
	 * @param int $limit
61
	 * @param int $offset
62
	 * @return Notification[]
63
	 */
64
	public function findAll($limit = null, $offset = null) {
65
		$sql = 'SELECT * FROM ' . $this->getTableName();
0 ignored issues
show
Deprecated Code introduced by
The function OCP\AppFramework\Db\Mapper::getTableName() has been deprecated: 14.0.0 Move over to QBMapper ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

65
		$sql = 'SELECT * FROM ' . /** @scrutinizer ignore-deprecated */ $this->getTableName();

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
66
		return $this->findEntities($sql, [], $limit, $offset);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\AppFramework\Db\Mapper::findEntities() has been deprecated: 14.0.0 Move over to QBMapper ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

66
		return /** @scrutinizer ignore-deprecated */ $this->findEntities($sql, [], $limit, $offset);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
67
	}
68
69
	/**
70
	 * @param int $pollId
71
	 * @param int $limit
72
	 * @param int $offset
73
	 * @return Notification[]
74
	 */
75
	public function findAllByPoll($pollId, $limit = null, $offset = null) {
76
		$sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ?';
0 ignored issues
show
Deprecated Code introduced by
The function OCP\AppFramework\Db\Mapper::getTableName() has been deprecated: 14.0.0 Move over to QBMapper ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

76
		$sql = 'SELECT * FROM ' . /** @scrutinizer ignore-deprecated */ $this->getTableName() . ' WHERE poll_id = ?';

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
77
		return $this->findEntities($sql, [$pollId], $limit, $offset);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\AppFramework\Db\Mapper::findEntities() has been deprecated: 14.0.0 Move over to QBMapper ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

77
		return /** @scrutinizer ignore-deprecated */ $this->findEntities($sql, [$pollId], $limit, $offset);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
78
	}
79
80
	/**
81
	 * @param int $pollId
82
	 * @param string $userId
83
	 * @throws \OCP\AppFramework\Db\DoesNotExistException if not found
84
	 * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
85
	 * @return Notification
86
	 */
87
	public function findByUserAndPoll($pollId, $userId) {
88
		$sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ? AND user_id = ?';
0 ignored issues
show
Deprecated Code introduced by
The function OCP\AppFramework\Db\Mapper::getTableName() has been deprecated: 14.0.0 Move over to QBMapper ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

88
		$sql = 'SELECT * FROM ' . /** @scrutinizer ignore-deprecated */ $this->getTableName() . ' WHERE poll_id = ? AND user_id = ?';

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
89
		return $this->findEntity($sql, [$pollId, $userId]);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\AppFramework\Db\Mapper::findEntity() has been deprecated: 14.0.0 Move over to QBMapper ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

89
		return /** @scrutinizer ignore-deprecated */ $this->findEntity($sql, [$pollId, $userId]);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
90
	}
91
92
	/**
93
	 * @param int $pollId
94
	 */
95
	public function deleteByPoll($pollId) {
96
		$sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ?';
0 ignored issues
show
Deprecated Code introduced by
The function OCP\AppFramework\Db\Mapper::getTableName() has been deprecated: 14.0.0 Move over to QBMapper ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

96
		$sql = 'DELETE FROM ' . /** @scrutinizer ignore-deprecated */ $this->getTableName() . ' WHERE poll_id = ?';

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
97
		$this->execute($sql, [$pollId]);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\AppFramework\Db\Mapper::execute() has been deprecated: 14.0.0 Move over to QBMapper ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

97
		/** @scrutinizer ignore-deprecated */ $this->execute($sql, [$pollId]);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
98
	}
99
100
}
101