Converts 'strpos()' calls to improve code readability.

Signed-off-by: Faraz Samapoor <fsamapoor@gmail.com>
This commit is contained in:
Faraz Samapoor
2023-05-07 09:30:01 +03:30
parent ff234f68e1
commit b8566a3a0d
8 changed files with 15 additions and 15 deletions

View File

@@ -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'];
}