Converts 'strpos()' calls to improve code readability.
Signed-off-by: Faraz Samapoor <fsamapoor@gmail.com>
This commit is contained in:
@@ -53,7 +53,7 @@ class AttachmentController extends Controller {
|
||||
* @throws \OCA\Deck\NotFoundException
|
||||
*/
|
||||
public function display($cardId, $attachmentId) {
|
||||
if (strpos($attachmentId, ':') === false) {
|
||||
if (!str_contains($attachmentId, ':')) {
|
||||
$type = 'deck_file';
|
||||
} else {
|
||||
[$type, $attachmentId] = explode(':', $attachmentId);
|
||||
@@ -76,7 +76,7 @@ class AttachmentController extends Controller {
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function update($cardId, $attachmentId) {
|
||||
if (strpos($attachmentId, ':') === false) {
|
||||
if (!str_contains($attachmentId, ':')) {
|
||||
$type = 'deck_file';
|
||||
} else {
|
||||
[$type, $attachmentId] = explode(':', $attachmentId);
|
||||
@@ -88,7 +88,7 @@ class AttachmentController extends Controller {
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function delete($cardId, $attachmentId) {
|
||||
if (strpos($attachmentId, ':') === false) {
|
||||
if (!str_contains($attachmentId, ':')) {
|
||||
$type = 'deck_file';
|
||||
} else {
|
||||
[$type, $attachmentId] = explode(':', $attachmentId);
|
||||
@@ -100,7 +100,7 @@ class AttachmentController extends Controller {
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function restore($cardId, $attachmentId) {
|
||||
if (strpos($attachmentId, ':') === false) {
|
||||
if (!str_contains($attachmentId, ':')) {
|
||||
$type = 'deck_file';
|
||||
} else {
|
||||
[$type, $attachmentId] = explode(':', $attachmentId);
|
||||
|
||||
@@ -68,7 +68,7 @@ class RelationalEntity extends Entity implements \JsonSerializable {
|
||||
$reflection = new \ReflectionClass($this);
|
||||
$json = [];
|
||||
foreach ($properties as $property => $value) {
|
||||
if (strpos($property, '_') !== 0 && $reflection->hasProperty($property)) {
|
||||
if (!str_starts_with($property, '_') && $reflection->hasProperty($property)) {
|
||||
$propertyReflection = $reflection->getProperty($property);
|
||||
if (!$propertyReflection->isPrivate() && !in_array($property, $this->_resolvedProperties, true)) {
|
||||
$json[$property] = $this->getter($property);
|
||||
@@ -129,7 +129,7 @@ class RelationalEntity extends Entity implements \JsonSerializable {
|
||||
|
||||
public function __call(string $methodName, array $args) {
|
||||
$attr = lcfirst(substr($methodName, 7));
|
||||
if (array_key_exists($attr, $this->_resolvedProperties) && strpos($methodName, 'resolve') === 0) {
|
||||
if (array_key_exists($attr, $this->_resolvedProperties) && str_starts_with($methodName, 'resolve')) {
|
||||
if ($this->_resolvedProperties[$attr] !== null) {
|
||||
return $this->_resolvedProperties[$attr];
|
||||
}
|
||||
@@ -137,7 +137,7 @@ class RelationalEntity extends Entity implements \JsonSerializable {
|
||||
}
|
||||
|
||||
$attr = lcfirst(substr($methodName, 3));
|
||||
if (array_key_exists($attr, $this->_resolvedProperties) && strpos($methodName, 'set') === 0) {
|
||||
if (array_key_exists($attr, $this->_resolvedProperties) && str_starts_with($methodName, 'set')) {
|
||||
if (!is_scalar($args[0])) {
|
||||
$args[0] = $args[0]['primaryKey'];
|
||||
}
|
||||
|
||||
@@ -51,11 +51,11 @@ class BeforeTemplateRenderedListener implements IEventListener {
|
||||
Util::addStyle('deck', 'deck');
|
||||
|
||||
$pathInfo = $this->request->getPathInfo();
|
||||
if (strpos($pathInfo, '/apps/calendar') === 0) {
|
||||
if (str_starts_with($pathInfo, '/apps/calendar')) {
|
||||
Util::addScript('deck', 'deck-calendar');
|
||||
}
|
||||
|
||||
if (strpos($pathInfo, '/call/') === 0 || strpos($pathInfo, '/apps/spreed') === 0) {
|
||||
if (str_starts_with($pathInfo, '/call/') || str_starts_with($pathInfo, '/apps/spreed')) {
|
||||
Util::addScript('deck', 'deck-talk');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class ResourceAdditionalScriptsListener implements IEventListener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (strpos($this->request->getPathInfo(), '/call/') === 0) {
|
||||
if (str_starts_with($this->request->getPathInfo(), '/call/')) {
|
||||
// Talk integration has its own entrypoint which already includes collections handling
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ class ExceptionMiddleware extends Middleware {
|
||||
], $exception->getStatus());
|
||||
}
|
||||
|
||||
if (strpos(get_class($controller), 'OCA\\Deck\\Controller\\') === 0) {
|
||||
if (str_starts_with(get_class($controller), 'OCA\\Deck\\Controller\\')) {
|
||||
$response = [
|
||||
'status' => 500,
|
||||
'message' => $exceptionMessage,
|
||||
|
||||
@@ -71,7 +71,7 @@ class FilterStringParser {
|
||||
}
|
||||
|
||||
private function parseFilterToken(SearchQuery $query, string $token): bool {
|
||||
if (strpos($token, ':') === false) {
|
||||
if (!str_contains($token, ':')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ abstract class BaseValidator {
|
||||
// The format for specifying validation rules and parameters follows an
|
||||
// easy {rule}:{parameters} formatting convention. For instance the
|
||||
// rule "Max:3" states that the value may only be three letters.
|
||||
if (strpos($rule, ':') !== false) {
|
||||
if (str_contains($rule, ':')) {
|
||||
[$rule, $parameter] = explode(':', $rule, 2);
|
||||
if (!$this->{$rule}($value, $parameter)) {
|
||||
throw new BadRequestException(
|
||||
|
||||
@@ -98,7 +98,7 @@ class ActivityManagerTest extends TestCase {
|
||||
->willReturn($this->l10n);
|
||||
|
||||
foreach ($managerClass->getConstants() as $constant => $value) {
|
||||
if (strpos($constant, 'SUBJECT') === 0) {
|
||||
if (str_starts_with($constant, 'SUBJECT')) {
|
||||
$format = $this->activityManager->getActivityFormat('cz', $value, [], false);
|
||||
if ($format !== '') {
|
||||
$this->assertStringContainsString('{user}', $format);
|
||||
|
||||
Reference in New Issue
Block a user