Skip to content

Commit

Permalink
Refactors "strpos" calls in lib/public to improve code readability.
Browse files Browse the repository at this point in the history
Signed-off-by: Faraz Samapoor <fsamapoor@gmail.com>
  • Loading branch information
Faraz Samapoor committed May 15, 2023
1 parent 8bdb50f commit 1622ce7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/public/AppFramework/Db/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ protected function getter(string $name): mixed {
* @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)));
Expand All @@ -181,9 +181,9 @@ public function __call(string $methodName, array $args) {
* @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;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/public/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public static function addScript(string $application, string $file = null, strin
// need separate handling
if ($application !== 'core'
&& $file !== null
&& strpos($file, 'l10n') === false) {
&& !str_contains($file, 'l10n')) {
self::addTranslations($application);
}

Expand Down

0 comments on commit 1622ce7

Please sign in to comment.