Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Rearrange structure
Sobunoafc9ea08f379
diff --git a/app/Support/Search/OperatorQuerySearch.php b/app/Support/Search/OperatorQuerySearch.phpindex 596aedd7d0..4e9408a3a8 100644--- a/app/Support/Search/OperatorQuerySearch.php+++ b/app/Support/Search/OperatorQuerySearch.php@@ -39,6 +39,11 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;use FireflyIII\Repositories\Category\CategoryRepositoryInterface;use FireflyIII\Repositories\Tag\TagRepositoryInterface;use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;+use FireflyIII\Support\Search\QueryParser\QueryParserInterface;+use FireflyIII\Support\Search\QueryParser\Node;+use FireflyIII\Support\Search\QueryParser\Field;+use FireflyIII\Support\Search\QueryParser\Word;+use FireflyIII\Support\Search\QueryParser\Subquery;use FireflyIII\Support\ParseDateString;use FireflyIII\User;use Illuminate\Pagination\LengthAwarePaginator;diff --git a/app/Support/Search/QueryParser/Field.php b/app/Support/Search/QueryParser/Field.phpnew file mode 100644index 0000000000..3028af9730--- /dev/null+++ b/app/Support/Search/QueryParser/Field.php@@ -0,0 +1,36 @@+<?php++declare(strict_types=1);++namespace FireflyIII\Support\Search\QueryParser;++/**+ * Represents a field operator with value (e.g. amount:100)+ */+class Field extends Node+{+ private string $operator;+ private string $value;++ public function __construct(string $operator, string $value, bool $prohibited = false)+ {+ $this->operator = $operator;+ $this->value = $value;+ $this->prohibited = $prohibited;+ }++ public function getOperator(): string+ {+ return $this->operator;+ }++ public function getValue(): string+ {+ return $this->value;+ }++ public function __toString(): string+ {+ return ($this->prohibited ? '-' : '') . $this->operator . ':' . $this->value;+ }+}diff --git a/app/Support/Search/GdbotsQueryParser.php b/app/Support/Search/QueryParser/GdbotsQueryParser.phpsimilarity index 98%rename from app/Support/Search/GdbotsQueryParser.phprename to app/Support/Search/QueryParser/GdbotsQueryParser.phpindex c8249c455a..8a56d0f6de 100644--- a/app/Support/Search/GdbotsQueryParser.php+++ b/app/Support/Search/QueryParser/GdbotsQueryParser.php@@ -2,7 +2,7 @@declare(strict_types=1);-namespace FireflyIII\Support\Search;+namespace FireflyIII\Support\Search\QueryParser;use FireflyIII\Exceptions\FireflyException;use Gdbots\QueryParser\QueryParser as BaseQueryParser;diff --git a/app/Support/Search/QueryParser/Node.php b/app/Support/Search/QueryParser/Node.phpnew file mode 100644index 0000000000..7dced2e759--- /dev/null+++ b/app/Support/Search/QueryParser/Node.php@@ -0,0 +1,20 @@+<?php++declare(strict_types=1);++namespace FireflyIII\Support\Search\QueryParser;++/**+ * Base class for all nodes+ */+abstract class Node+{+ abstract public function __toString(): string;++ protected bool $prohibited;++ public function isProhibited(): bool+ {+ return $this->prohibited;+ }+}diff --git a/app/Support/Search/QueryParser.php b/app/Support/Search/QueryParser/QueryParser.phpsimilarity index 99%rename from app/Support/Search/QueryParser.phprename to app/Support/Search/QueryParser/QueryParser.phpindex 19a1c678ca..1d7f0658c9 100644--- a/app/Support/Search/QueryParser.php+++ b/app/Support/Search/QueryParser/QueryParser.php@@ -2,7 +2,7 @@declare(strict_types=1);-namespace FireflyIII\Support\Search;+namespace FireflyIII\Support\Search\QueryParser;/*** Represents a result from parsing a query nodediff --git a/app/Support/Search/QueryParser/QueryParserInterface.php b/app/Support/Search/QueryParser/QueryParserInterface.phpnew file mode 100644index 0000000000..831baf1270--- /dev/null+++ b/app/Support/Search/QueryParser/QueryParserInterface.php@@ -0,0 +1,13 @@+<?php++declare(strict_types=1);++namespace FireflyIII\Support\Search\QueryParser;++interface QueryParserInterface+{+ /**+ * @return Node[]+ */+ public function parse(string $query): array;+}diff --git a/app/Support/Search/QueryParser/Subquery.php b/app/Support/Search/QueryParser/Subquery.phpnew file mode 100644index 0000000000..9336ce0a62--- /dev/null+++ b/app/Support/Search/QueryParser/Subquery.php@@ -0,0 +1,38 @@+<?php++declare(strict_types=1);++namespace FireflyIII\Support\Search\QueryParser;++/**+ * Represents a subquery (group of nodes)+ */+class Subquery extends Node+{+ /** @var Node[] */+ private array $nodes;++ /**+ * @param Node[] $nodes+ * @param bool $prohibited+ */+ public function __construct(array $nodes, bool $prohibited = false)+ {+ $this->nodes = $nodes;+ $this->prohibited = $prohibited;+ }++ /**+ * @return Node[]+ */+ public function getNodes(): array+ {+ return $this->nodes;+ }+++ public function __toString(): string+ {+ return ($this->prohibited ? '-' : '') . '(' . implode(' ', array_map(fn($node) => (string)$node, $this->nodes)) . ')';+ }+}diff --git a/app/Support/Search/QueryParser/Word.php b/app/Support/Search/QueryParser/Word.phpnew file mode 100644index 0000000000..d7c12b6976--- /dev/null+++ b/app/Support/Search/QueryParser/Word.php@@ -0,0 +1,29 @@+<?php++declare(strict_types=1);++namespace FireflyIII\Support\Search\QueryParser;++/**+ * Represents a word in the search query, meaning either a single-word without spaces or a quote-delimited string+ */+class Word extends Node+{+ private string $value;++ public function __construct(string $value, bool $prohibited = false)+ {+ $this->value = $value;+ $this->prohibited = $prohibited;+ }++ public function getValue(): string+ {+ return $this->value;+ }++ public function __toString(): string+ {+ return ($this->prohibited ? '-' : '') . $this->value;+ }+}diff --git a/app/Support/Search/QueryParserInterface.php b/app/Support/Search/QueryParserInterface.phpdeleted file mode 100644index 93f88d1e75..0000000000--- a/app/Support/Search/QueryParserInterface.php+++ /dev/null@@ -1,127 +0,0 @@-<?php--declare(strict_types=1);--namespace FireflyIII\Support\Search;--interface QueryParserInterface-{- /**- * @return Node[]- */- public function parse(string $query): array;-}---/**- * Base class for all nodes- */-abstract class Node-{- abstract public function __toString(): string;-}--/**- * Represents a word in the search query- */-class Word extends Node-{- private string $value;- private bool $prohibited;-- public function __construct(string $value, bool $prohibited = false)- {- $this->value = $value;- $this->prohibited = $prohibited;- }-- public function getValue(): string- {- return $this->value;- }-- public function isProhibited(): bool- {- return $this->prohibited;- }-- public function __toString(): string- {- return ($this->prohibited ? '-' : '') . $this->value;- }-}--/**- * Represents a field operator with value (e.g. amount:100)- */-class Field extends Node-{- private string $operator;- private string $value;- private bool $prohibited;-- public function __construct(string $operator, string $value, bool $prohibited = false)- {- $this->operator = $operator;- $this->value = $value;- $this->prohibited = $prohibited;- }-- public function getOperator(): string- {- return $this->operator;- }-- public function getValue(): string- {- return $this->value;- }-- public function isProhibited(): bool- {- return $this->prohibited;- }-- public function __toString(): string- {- return ($this->prohibited ? '-' : '') . $this->operator . ':' . $this->value;- }-}--/**- * Represents a subquery (group of nodes)- */-class Subquery extends Node-{- /** @var Node[] */- private array $nodes;-- private bool $prohibited;-- /**- * @param Node[] $nodes- */- public function __construct(array $nodes, bool $prohibited = false)- {- $this->nodes = $nodes;- $this->prohibited = $prohibited;- }-- /**- * @return Node[]- */- public function getNodes(): array- {- return $this->nodes;- }-- public function isProhibited(): bool- {- return $this->prohibited;- }-- public function __toString(): string- {- return ($this->prohibited ? '-' : '') . '(' . implode(' ', array_map(fn($node) => (string)$node, $this->nodes)) . ')';- }-}