Removed apply parameter name to better reflect the action taken.

This commit is contained in:
Abdulmhsen B. A. A
2022-05-25 07:01:37 +03:00
parent e7acfc6d86
commit eef22ab926
3 changed files with 10 additions and 11 deletions

View File

@@ -218,9 +218,9 @@ final class StateEntity implements iFace
return $rPointers;
}
public function apply(iFace $entity, bool $metadataOnly = false): self
public function apply(iFace $entity, bool $essentialOnly = false): self
{
if (true === $metadataOnly) {
if (true === $essentialOnly) {
foreach (iFace::ENTITY_FORCE_UPDATE_FIELDS as $key) {
if (true === $this->isEqualValue($key, $entity)) {
continue;
@@ -308,9 +308,6 @@ final class StateEntity implements iFace
$this->watched = 0;
$this->updated = time();
// -- no isset check is intentional, this should throw error as condition are not met.
unset($this->metadata[$remote->via][iFace::COLUMN_META_DATA_PLAYED_AT]);
return $this;
}

View File

@@ -59,6 +59,8 @@ interface StateInterface
self::COLUMN_VIA,
self::COLUMN_TITLE,
self::COLUMN_YEAR,
self::COLUMN_SEASON,
self::COLUMN_EPISODE,
self::COLUMN_EXTRA,
];
@@ -201,11 +203,11 @@ interface StateInterface
* Apply changes to entity.
*
* @param StateInterface $entity
* @param bool $metadataOnly
* @param bool $essentialOnly Only Update {@see StateInterface::ENTITY_FORCE_UPDATE_FIELDS}
*
* @return StateInterface
*/
public function apply(StateInterface $entity, bool $metadataOnly = false): StateInterface;
public function apply(StateInterface $entity, bool $essentialOnly = false): StateInterface;
/**
* Update Original data.

View File

@@ -320,8 +320,8 @@ final class Initializer
$cloned = clone $backend;
if (true === $entity->isTainted()) {
if ($cloned->apply(entity: $entity, metadataOnly: true)->isChanged()) {
$backend = $storage->update($backend->apply(entity: $entity, metadataOnly: true));
if ($cloned->apply(entity: $entity, essentialOnly: true)->isChanged()) {
$backend = $storage->update($backend->apply(entity: $entity, essentialOnly: true));
return jsonResponse(
status: 200,
body: $backend->getAll(),
@@ -336,8 +336,8 @@ final class Initializer
}
if ($backend->updated >= $entity->updated) {
if ($cloned->apply(entity: $entity, metadataOnly: true)->isChanged()) {
$backend = $storage->update($backend->apply(entity: $entity, metadataOnly: true));
if ($cloned->apply(entity: $entity, essentialOnly: true)->isChanged()) {
$backend = $storage->update($backend->apply(entity: $entity, essentialOnly: true));
return jsonResponse(
status: 200,
body: $backend->getAll(),