mirror of
https://github.com/JanGross/quicknotes.git
synced 2025-11-30 23:37:16 +01:00
Add return types to ColorMapper
This commit is contained in:
@@ -5,28 +5,30 @@ use OCP\IDBConnection;
|
|||||||
use OCP\AppFramework\Db\Mapper;
|
use OCP\AppFramework\Db\Mapper;
|
||||||
use OCP\AppFramework\Db\DoesNotExistException;
|
use OCP\AppFramework\Db\DoesNotExistException;
|
||||||
|
|
||||||
|
use OCA\QuickNotes\Db\Color;
|
||||||
|
|
||||||
class ColorMapper extends Mapper {
|
class ColorMapper extends Mapper {
|
||||||
|
|
||||||
public function __construct(IDBConnection $db) {
|
public function __construct(IDBConnection $db) {
|
||||||
parent::__construct($db, 'quicknotes_colors', '\OCA\QuickNotes\Db\Color');
|
parent::__construct($db, 'quicknotes_colors', '\OCA\QuickNotes\Db\Color');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function find($id) {
|
public function find($id): Color {
|
||||||
$sql = 'SELECT * FROM *PREFIX*quicknotes_colors WHERE id = ?';
|
$sql = 'SELECT * FROM *PREFIX*quicknotes_colors WHERE id = ?';
|
||||||
return $this->findEntity($sql, [$id]);
|
return $this->findEntity($sql, [$id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findAll() {
|
public function findAll(): array {
|
||||||
$sql = 'SELECT * FROM *PREFIX*quicknotes_colors';
|
$sql = 'SELECT * FROM *PREFIX*quicknotes_colors';
|
||||||
return $this->findEntities($sql, []);
|
return $this->findEntities($sql, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findByColor($color) {
|
public function findByColor(string $color): Color {
|
||||||
$sql = 'SELECT * FROM *PREFIX*quicknotes_colors WHERE color = ?';
|
$sql = 'SELECT * FROM *PREFIX*quicknotes_colors WHERE color = ?';
|
||||||
return $this->findEntity($sql, [$color]);
|
return $this->findEntity($sql, [$color]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function colorExists($color) {
|
public function colorExists(string $color): bool {
|
||||||
$sql = 'SELECT * FROM *PREFIX*quicknotes_colors WHERE color = ?';
|
$sql = 'SELECT * FROM *PREFIX*quicknotes_colors WHERE color = ?';
|
||||||
try {
|
try {
|
||||||
$this->findEntity($sql, [$color]);
|
$this->findEntity($sql, [$color]);
|
||||||
|
|||||||
Reference in New Issue
Block a user