Added boolean getters to IDbResult.
This commit is contained in:
parent
5bd40795a0
commit
c563bb20e8
4 changed files with 33 additions and 1 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
0.2311.91351
|
||||
0.2311.91403
|
||||
|
|
|
@ -29,4 +29,12 @@ trait DbResultTrait {
|
|||
public function getFloatOrNull(int|string $index): ?float {
|
||||
return $this->isNull($index) ? null : (float)$this->getValue($index);
|
||||
}
|
||||
|
||||
public function getBoolean(int|string $index): bool {
|
||||
return $this->getInteger($index) !== 0;
|
||||
}
|
||||
|
||||
public function getBooleanOrNull(int|string $index): ?bool {
|
||||
return $this->isNull($index) ? null : ($this->getInteger($index) !== 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,6 +83,22 @@ interface IDbResult extends ICloseable {
|
|||
*/
|
||||
function getFloatOrNull(int|string $index): ?float;
|
||||
|
||||
/**
|
||||
* Gets the value from the target index cast as a boolean value.
|
||||
*
|
||||
* @param int|string $index Target index.
|
||||
* @return bool Returns the value cast to a boolean value.
|
||||
*/
|
||||
function getBoolean(int|string $index): bool;
|
||||
|
||||
/**
|
||||
* Checks if the field is null, then gets the value from the target index cast as a boolean value.
|
||||
*
|
||||
* @param int|string $index Target index.
|
||||
* @return ?bool Returns the value cast to a boolean value or null.
|
||||
*/
|
||||
function getBooleanOrNull(int|string $index): ?bool;
|
||||
|
||||
/**
|
||||
* Gets the value from the target index as a Stream.
|
||||
*
|
||||
|
|
|
@ -48,6 +48,14 @@ class NullDbResult implements IDbResult {
|
|||
return null;
|
||||
}
|
||||
|
||||
public function getBoolean(int|string $index): bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getBooleanOrNull(int|string $index): ?bool {
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getStream(int|string $index): ?Stream {
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue