mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 13:12:41 +00:00
Clean up coontext classes
This commit is contained in:
parent
983fa58ec8
commit
308b592b18
7 changed files with 57 additions and 78 deletions
|
@ -10,25 +10,6 @@ abstract class AbstractContext {
|
|||
protected $props = [];
|
||||
protected $parent = null;
|
||||
|
||||
public function __construct(self $c = null) {
|
||||
$this->parent = $c;
|
||||
}
|
||||
|
||||
public function __clone() {
|
||||
// if the context was cloned because its parent was cloned, change the parent to the clone
|
||||
if ($this->parent) {
|
||||
$t = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS | \DEBUG_BACKTRACE_PROVIDE_OBJECT, 2)[1];
|
||||
if (($t['object'] ?? null) instanceof self && $t['function'] === "__clone") {
|
||||
$this->parent = $t['object'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @codeCoverageIgnore */
|
||||
public function __destruct() {
|
||||
unset($this->parent);
|
||||
}
|
||||
|
||||
protected function act(string $prop, int $set, $value) {
|
||||
if ($set) {
|
||||
if (is_null($value)) {
|
||||
|
|
|
@ -6,7 +6,13 @@
|
|||
declare(strict_types=1);
|
||||
namespace JKingWeb\Arsse\Context;
|
||||
|
||||
trait BooleanMethods {
|
||||
trait BooleanMembers {
|
||||
public $unread = null;
|
||||
public $starred = null;
|
||||
public $hidden = null;
|
||||
public $labelled = null;
|
||||
public $annotated = null;
|
||||
|
||||
public function unread(bool $spec = null) {
|
||||
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
/** @license MIT
|
||||
* Copyright 2017 J. King, Dustin Wilson et al.
|
||||
* See LICENSE and AUTHORS files for details */
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace JKingWeb\Arsse\Context;
|
||||
|
||||
trait BooleanProperties {
|
||||
public $unread = null;
|
||||
public $starred = null;
|
||||
public $hidden = null;
|
||||
public $labelled = null;
|
||||
public $annotated = null;
|
||||
}
|
|
@ -7,10 +7,8 @@ declare(strict_types=1);
|
|||
namespace JKingWeb\Arsse\Context;
|
||||
|
||||
class Context extends AbstractContext {
|
||||
use BooleanMethods;
|
||||
use BooleanProperties;
|
||||
use ExclusionMethods;
|
||||
use ExclusionProperties;
|
||||
use BooleanMembers;
|
||||
use ExclusionMembers;
|
||||
|
||||
/** @var ExclusionContext */
|
||||
public $not;
|
||||
|
|
|
@ -7,6 +7,24 @@ declare(strict_types=1);
|
|||
namespace JKingWeb\Arsse\Context;
|
||||
|
||||
class ExclusionContext extends AbstractContext {
|
||||
use ExclusionMethods;
|
||||
use ExclusionProperties;
|
||||
use ExclusionMembers;
|
||||
|
||||
public function __construct(Context $parent = null) {
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
public function __clone() {
|
||||
// if the context was cloned because its parent was cloned, change the parent to the clone
|
||||
if ($this->parent) {
|
||||
$t = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS | \DEBUG_BACKTRACE_PROVIDE_OBJECT, 2)[1];
|
||||
if (($t['object'] ?? null) instanceof Context && $t['function'] === "__clone") {
|
||||
$this->parent = $t['object'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @codeCoverageIgnore */
|
||||
public function __destruct() {
|
||||
unset($this->parent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,34 @@ namespace JKingWeb\Arsse\Context;
|
|||
use JKingWeb\Arsse\Misc\ValueInfo;
|
||||
use JKingWeb\Arsse\Misc\Date;
|
||||
|
||||
trait ExclusionMethods {
|
||||
trait ExclusionMembers {
|
||||
public $folder = null;
|
||||
public $folders = null;
|
||||
public $folderShallow = null;
|
||||
public $foldersShallow = null;
|
||||
public $tag = null;
|
||||
public $tags = null;
|
||||
public $tagName = null;
|
||||
public $tagNames = null;
|
||||
public $subscription = null;
|
||||
public $subscriptions = null;
|
||||
public $edition = null;
|
||||
public $editions = null;
|
||||
public $article = null;
|
||||
public $articles = null;
|
||||
public $label = null;
|
||||
public $labels = null;
|
||||
public $labelName = null;
|
||||
public $labelNames = null;
|
||||
public $annotationTerms = null;
|
||||
public $searchTerms = null;
|
||||
public $titleTerms = null;
|
||||
public $authorTerms = null;
|
||||
public $articleRange = [null, null];
|
||||
public $editionRange = [null, null];
|
||||
public $modifiedRange = [null, null];
|
||||
public $markedRange = [null, null];
|
||||
|
||||
protected function cleanIdArray(array $spec, bool $allowZero = false): array {
|
||||
$spec = array_values($spec);
|
||||
for ($a = 0; $a < sizeof($spec); $a++) {
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
/** @license MIT
|
||||
* Copyright 2017 J. King, Dustin Wilson et al.
|
||||
* See LICENSE and AUTHORS files for details */
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace JKingWeb\Arsse\Context;
|
||||
|
||||
trait ExclusionProperties {
|
||||
public $folder = null;
|
||||
public $folders = null;
|
||||
public $folderShallow = null;
|
||||
public $foldersShallow = null;
|
||||
public $tag = null;
|
||||
public $tags = null;
|
||||
public $tagName = null;
|
||||
public $tagNames = null;
|
||||
public $subscription = null;
|
||||
public $subscriptions = null;
|
||||
public $edition = null;
|
||||
public $editions = null;
|
||||
public $article = null;
|
||||
public $articles = null;
|
||||
public $label = null;
|
||||
public $labels = null;
|
||||
public $labelName = null;
|
||||
public $labelNames = null;
|
||||
public $annotationTerms = null;
|
||||
public $searchTerms = null;
|
||||
public $titleTerms = null;
|
||||
public $authorTerms = null;
|
||||
public $articleRange = [null, null];
|
||||
public $editionRange = [null, null];
|
||||
public $modifiedRange = [null, null];
|
||||
public $markedRange = [null, null];
|
||||
}
|
Loading…
Reference in a new issue