aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFaraz Samapoor <fsamapoor@gmail.com>2023-05-15 12:32:28 +0330
committerCôme Chilliet <91878298+come-nc@users.noreply.github.com>2023-06-05 11:14:52 +0200
commitbf38c0a3d1aaf58486d1a9e7af45f47bdf2e429d (patch)
treee309ad77e1e80ac2b2fc16a25d995ecc3c41d375
parent6a8c25f64e480229c88ac33e200f39aa9a049b99 (diff)
downloadnextcloud-server-bf38c0a3d1aaf58486d1a9e7af45f47bdf2e429d.tar.gz
nextcloud-server-bf38c0a3d1aaf58486d1a9e7af45f47bdf2e429d.zip
Refactors "strpos" calls in lib/public to improve code readability.
Signed-off-by: Faraz Samapoor <fsamapoor@gmail.com>
-rw-r--r--lib/public/AppFramework/Db/Entity.php8
-rw-r--r--lib/public/Util.php2
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/public/AppFramework/Db/Entity.php b/lib/public/AppFramework/Db/Entity.php
index 34cd297e57e..1ae938f6e32 100644
--- a/lib/public/AppFramework/Db/Entity.php
+++ b/lib/public/AppFramework/Db/Entity.php
@@ -163,9 +163,9 @@ abstract class Entity {
* @since 7.0.0
*/
public function __call(string $methodName, array $args) {
- if (strpos($methodName, 'set') === 0) {
+ if (str_starts_with($methodName, 'set')) {
$this->setter(lcfirst(substr($methodName, 3)), $args);
- } elseif (strpos($methodName, 'get') === 0) {
+ } elseif (str_starts_with($methodName, 'get')) {
return $this->getter(lcfirst(substr($methodName, 3)));
} elseif ($this->isGetterForBoolProperty($methodName)) {
return $this->getter(lcfirst(substr($methodName, 2)));
@@ -181,9 +181,9 @@ abstract class Entity {
* @since 18.0.0
*/
protected function isGetterForBoolProperty(string $methodName): bool {
- if (strpos($methodName, 'is') === 0) {
+ if (str_starts_with($methodName, 'is')) {
$fieldName = lcfirst(substr($methodName, 2));
- return isset($this->_fieldTypes[$fieldName]) && strpos($this->_fieldTypes[$fieldName], 'bool') === 0;
+ return isset($this->_fieldTypes[$fieldName]) && str_starts_with($this->_fieldTypes[$fieldName], 'bool');
}
return false;
}
diff --git a/lib/public/Util.php b/lib/public/Util.php
index f73c19e6dcd..5bb126d26b0 100644
--- a/lib/public/Util.php
+++ b/lib/public/Util.php
@@ -182,7 +182,7 @@ class Util {
// need separate handling
if ($application !== 'core'
&& $file !== null
- && strpos($file, 'l10n') === false) {
+ && !str_contains($file, 'l10n')) {
self::addTranslations($application);
}