diff --git a/Makefile b/Makefile index 6ce7257..9802d96 100644 --- a/Makefile +++ b/Makefile @@ -69,12 +69,8 @@ clean: rm -rf $(build_dir) rm -rf node_modules -# composer packages -composer: - composer install --prefer-dist - composer upgrade --prefer-dist -appstore: clean composer +appstore: clean mkdir -p $(sign_dir) rsync -a \ --exclude=/build \ @@ -88,9 +84,7 @@ appstore: clean composer --exclude=/CONTRIBUTING.md \ --exclude=/issue_template.md \ --exclude=/README.md \ - --exclude=/composer.json \ --exclude=/testConfiguration.json \ - --exclude=/composer.lock \ --exclude=/.gitattributes \ --exclude=/.gitignore \ --exclude=/.scrutinizer.yml \ diff --git a/composer.json b/composer.json deleted file mode 100644 index d88b8b8..0000000 --- a/composer.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "name": "nextcloud/files_fulltextsearch", - "description": "files_fulltextsearch", - "minimum-stability": "stable", - "license": "agpl", - "config": { - "optimize-autoloader": true, - "classmap-authoritative": true, - "autoloader-suffix": "Files_FullTextSearch" - }, - "authors": [ - { - "name": "Maxence Lange", - "email": "maxence@artificial-owl.com" - } - ], - "autoload": { - "psr-4": { - "OCA\\Files_FullTextSearch\\": "lib/" - } - }, - "scripts": { - "cs:fix": "php-cs-fixer fix", - "cs:check": "php-cs-fixer fix --dry-run --diff", - "lint": "find . -name \\*.php -not -path './vendor/*' -not -path './build/*' -not -path './node_modules/*' -print0 | xargs -0 -n1 php -l", - "psalm": "psalm", - "psalm:fix": "psalm --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType", - "psalm:update-baseline": "psalm --threads=1 --update-baseline" - }, - "require": { - "artificial-owl/my-small-php-tools": "~23" - }, - "require-dev": { - "nextcloud/coding-standard": "^1.0" - } -} diff --git a/composer.lock b/composer.lock deleted file mode 100644 index 068a6b1..0000000 --- a/composer.lock +++ /dev/null @@ -1,2195 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "436a54577cc2055904d8df1926374ab1", - "packages": [ - { - "name": "artificial-owl/my-small-php-tools", - "version": "v23.0.2", - "source": { - "type": "git", - "url": "https://github.com/ArtificialOwl/my-small-php-tools.git", - "reference": "0246b20ebffabcb1e929c71d3b0f221086f72db1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ArtificialOwl/my-small-php-tools/zipball/0246b20ebffabcb1e929c71d3b0f221086f72db1", - "reference": "0246b20ebffabcb1e929c71d3b0f221086f72db1", - "shasum": "" - }, - "require": { - "php": ">=7.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "ArtificialOwl\\MySmallPhpTools\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "AGPL-3.0-or-later" - ], - "authors": [ - { - "name": "Maxence Lange", - "email": "maxence@artificial-owl.com" - } - ], - "description": "My small PHP Tools", - "support": { - "issues": "https://github.com/ArtificialOwl/my-small-php-tools/issues", - "source": "https://github.com/ArtificialOwl/my-small-php-tools/tree/v23.0.2" - }, - "time": "2021-07-26T12:32:51+00:00" - } - ], - "packages-dev": [ - { - "name": "composer/pcre", - "version": "3.0.0", - "source": { - "type": "git", - "url": "https://github.com/composer/pcre.git", - "reference": "e300eb6c535192decd27a85bc72a9290f0d6b3bd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/e300eb6c535192decd27a85bc72a9290f0d6b3bd", - "reference": "e300eb6c535192decd27a85bc72a9290f0d6b3bd", - "shasum": "" - }, - "require": { - "php": "^7.4 || ^8.0" - }, - "require-dev": { - "phpstan/phpstan": "^1.3", - "phpstan/phpstan-strict-rules": "^1.1", - "symfony/phpunit-bridge": "^5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "3.x-dev" - } - }, - "autoload": { - "psr-4": { - "Composer\\Pcre\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" - } - ], - "description": "PCRE wrapping library that offers type-safe preg_* replacements.", - "keywords": [ - "PCRE", - "preg", - "regex", - "regular expression" - ], - "support": { - "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.0.0" - }, - "funding": [ - { - "url": "https://packagist.com", - "type": "custom" - }, - { - "url": "https://github.com/composer", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" - } - ], - "time": "2022-02-25T20:21:48+00:00" - }, - { - "name": "composer/semver", - "version": "3.3.2", - "source": { - "type": "git", - "url": "https://github.com/composer/semver.git", - "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/3953f23262f2bff1919fc82183ad9acb13ff62c9", - "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9", - "shasum": "" - }, - "require": { - "php": "^5.3.2 || ^7.0 || ^8.0" - }, - "require-dev": { - "phpstan/phpstan": "^1.4", - "symfony/phpunit-bridge": "^4.2 || ^5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "3.x-dev" - } - }, - "autoload": { - "psr-4": { - "Composer\\Semver\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nils Adermann", - "email": "naderman@naderman.de", - "homepage": "http://www.naderman.de" - }, - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" - }, - { - "name": "Rob Bast", - "email": "rob.bast@gmail.com", - "homepage": "http://robbast.nl" - } - ], - "description": "Semver library that offers utilities, version constraint parsing and validation.", - "keywords": [ - "semantic", - "semver", - "validation", - "versioning" - ], - "support": { - "irc": "irc://irc.freenode.org/composer", - "issues": "https://github.com/composer/semver/issues", - "source": "https://github.com/composer/semver/tree/3.3.2" - }, - "funding": [ - { - "url": "https://packagist.com", - "type": "custom" - }, - { - "url": "https://github.com/composer", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" - } - ], - "time": "2022-04-01T19:23:25+00:00" - }, - { - "name": "composer/xdebug-handler", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/composer/xdebug-handler.git", - "reference": "ced299686f41dce890debac69273b47ffe98a40c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/ced299686f41dce890debac69273b47ffe98a40c", - "reference": "ced299686f41dce890debac69273b47ffe98a40c", - "shasum": "" - }, - "require": { - "composer/pcre": "^1 || ^2 || ^3", - "php": "^7.2.5 || ^8.0", - "psr/log": "^1 || ^2 || ^3" - }, - "require-dev": { - "phpstan/phpstan": "^1.0", - "phpstan/phpstan-strict-rules": "^1.1", - "symfony/phpunit-bridge": "^6.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Composer\\XdebugHandler\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "John Stevenson", - "email": "john-stevenson@blueyonder.co.uk" - } - ], - "description": "Restarts a process without Xdebug.", - "keywords": [ - "Xdebug", - "performance" - ], - "support": { - "irc": "irc://irc.freenode.org/composer", - "issues": "https://github.com/composer/xdebug-handler/issues", - "source": "https://github.com/composer/xdebug-handler/tree/3.0.3" - }, - "funding": [ - { - "url": "https://packagist.com", - "type": "custom" - }, - { - "url": "https://github.com/composer", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" - } - ], - "time": "2022-02-25T21:32:43+00:00" - }, - { - "name": "doctrine/annotations", - "version": "1.13.2", - "source": { - "type": "git", - "url": "https://github.com/doctrine/annotations.git", - "reference": "5b668aef16090008790395c02c893b1ba13f7e08" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/5b668aef16090008790395c02c893b1ba13f7e08", - "reference": "5b668aef16090008790395c02c893b1ba13f7e08", - "shasum": "" - }, - "require": { - "doctrine/lexer": "1.*", - "ext-tokenizer": "*", - "php": "^7.1 || ^8.0", - "psr/cache": "^1 || ^2 || ^3" - }, - "require-dev": { - "doctrine/cache": "^1.11 || ^2.0", - "doctrine/coding-standard": "^6.0 || ^8.1", - "phpstan/phpstan": "^0.12.20", - "phpunit/phpunit": "^7.5 || ^8.0 || ^9.1.5", - "symfony/cache": "^4.4 || ^5.2" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "Docblock Annotations Parser", - "homepage": "https://www.doctrine-project.org/projects/annotations.html", - "keywords": [ - "annotations", - "docblock", - "parser" - ], - "support": { - "issues": "https://github.com/doctrine/annotations/issues", - "source": "https://github.com/doctrine/annotations/tree/1.13.2" - }, - "time": "2021-08-05T19:00:23+00:00" - }, - { - "name": "doctrine/lexer", - "version": "1.2.3", - "source": { - "type": "git", - "url": "https://github.com/doctrine/lexer.git", - "reference": "c268e882d4dbdd85e36e4ad69e02dc284f89d229" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/lexer/zipball/c268e882d4dbdd85e36e4ad69e02dc284f89d229", - "reference": "c268e882d4dbdd85e36e4ad69e02dc284f89d229", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0" - }, - "require-dev": { - "doctrine/coding-standard": "^9.0", - "phpstan/phpstan": "^1.3", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "vimeo/psalm": "^4.11" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.", - "homepage": "https://www.doctrine-project.org/projects/lexer.html", - "keywords": [ - "annotations", - "docblock", - "lexer", - "parser", - "php" - ], - "support": { - "issues": "https://github.com/doctrine/lexer/issues", - "source": "https://github.com/doctrine/lexer/tree/1.2.3" - }, - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Flexer", - "type": "tidelift" - } - ], - "time": "2022-02-28T11:07:21+00:00" - }, - { - "name": "friendsofphp/php-cs-fixer", - "version": "v3.8.0", - "source": { - "type": "git", - "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "cbad1115aac4b5c3c5540e7210d3c9fba2f81fa3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/cbad1115aac4b5c3c5540e7210d3c9fba2f81fa3", - "reference": "cbad1115aac4b5c3c5540e7210d3c9fba2f81fa3", - "shasum": "" - }, - "require": { - "composer/semver": "^3.2", - "composer/xdebug-handler": "^3.0.3", - "doctrine/annotations": "^1.13", - "ext-json": "*", - "ext-tokenizer": "*", - "php": "^7.4 || ^8.0", - "php-cs-fixer/diff": "^2.0", - "symfony/console": "^5.4 || ^6.0", - "symfony/event-dispatcher": "^5.4 || ^6.0", - "symfony/filesystem": "^5.4 || ^6.0", - "symfony/finder": "^5.4 || ^6.0", - "symfony/options-resolver": "^5.4 || ^6.0", - "symfony/polyfill-mbstring": "^1.23", - "symfony/polyfill-php80": "^1.25", - "symfony/polyfill-php81": "^1.25", - "symfony/process": "^5.4 || ^6.0", - "symfony/stopwatch": "^5.4 || ^6.0" - }, - "require-dev": { - "justinrainbow/json-schema": "^5.2", - "keradus/cli-executor": "^1.5", - "mikey179/vfsstream": "^1.6.10", - "php-coveralls/php-coveralls": "^2.5.2", - "php-cs-fixer/accessible-object": "^1.1", - "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.2", - "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.2.1", - "phpspec/prophecy": "^1.15", - "phpspec/prophecy-phpunit": "^2.0", - "phpunit/phpunit": "^9.5", - "phpunitgoodpractices/polyfill": "^1.5", - "phpunitgoodpractices/traits": "^1.9.1", - "symfony/phpunit-bridge": "^6.0", - "symfony/yaml": "^5.4 || ^6.0" - }, - "suggest": { - "ext-dom": "For handling output formats in XML", - "ext-mbstring": "For handling non-UTF8 characters." - }, - "bin": [ - "php-cs-fixer" - ], - "type": "application", - "autoload": { - "psr-4": { - "PhpCsFixer\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Dariusz RumiƄski", - "email": "dariusz.ruminski@gmail.com" - } - ], - "description": "A tool to automatically fix PHP code style", - "support": { - "issues": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues", - "source": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/tree/v3.8.0" - }, - "funding": [ - { - "url": "https://github.com/keradus", - "type": "github" - } - ], - "time": "2022-03-18T17:20:59+00:00" - }, - { - "name": "nextcloud/coding-standard", - "version": "v1.0.0", - "source": { - "type": "git", - "url": "https://github.com/nextcloud/coding-standard.git", - "reference": "f3d1f9375e89c605deb1734f59a9f51ecbe80578" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nextcloud/coding-standard/zipball/f3d1f9375e89c605deb1734f59a9f51ecbe80578", - "reference": "f3d1f9375e89c605deb1734f59a9f51ecbe80578", - "shasum": "" - }, - "require": { - "friendsofphp/php-cs-fixer": "^3.2", - "php": "^7.3|^8.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Nextcloud\\CodingStandard\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christoph Wurst", - "email": "christoph@winzerhof-wurst.at" - } - ], - "description": "Nextcloud coding standards for the php cs fixer", - "support": { - "issues": "https://github.com/nextcloud/coding-standard/issues", - "source": "https://github.com/nextcloud/coding-standard/tree/v1.0.0" - }, - "time": "2021-11-10T08:44:10+00:00" - }, - { - "name": "php-cs-fixer/diff", - "version": "v2.0.2", - "source": { - "type": "git", - "url": "https://github.com/PHP-CS-Fixer/diff.git", - "reference": "29dc0d507e838c4580d018bd8b5cb412474f7ec3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/29dc0d507e838c4580d018bd8b5cb412474f7ec3", - "reference": "29dc0d507e838c4580d018bd8b5cb412474f7ec3", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0 || ^8.0" - }, - "require-dev": { - "phpunit/phpunit": "^5.7.23 || ^6.4.3 || ^7.0", - "symfony/process": "^3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - } - ], - "description": "sebastian/diff v3 backport support for PHP 5.6+", - "homepage": "https://github.com/PHP-CS-Fixer", - "keywords": [ - "diff" - ], - "support": { - "issues": "https://github.com/PHP-CS-Fixer/diff/issues", - "source": "https://github.com/PHP-CS-Fixer/diff/tree/v2.0.2" - }, - "time": "2020-10-14T08:32:19+00:00" - }, - { - "name": "psr/cache", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/cache.git", - "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", - "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Cache\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for caching libraries", - "keywords": [ - "cache", - "psr", - "psr-6" - ], - "support": { - "source": "https://github.com/php-fig/cache/tree/master" - }, - "time": "2016-08-06T20:24:11+00:00" - }, - { - "name": "psr/container", - "version": "1.1.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", - "shasum": "" - }, - "require": { - "php": ">=7.4.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ], - "support": { - "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/1.1.2" - }, - "time": "2021-11-05T16:50:12+00:00" - }, - { - "name": "psr/event-dispatcher", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/event-dispatcher.git", - "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0", - "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0", - "shasum": "" - }, - "require": { - "php": ">=7.2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\EventDispatcher\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Standard interfaces for event handling.", - "keywords": [ - "events", - "psr", - "psr-14" - ], - "support": { - "issues": "https://github.com/php-fig/event-dispatcher/issues", - "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0" - }, - "time": "2019-01-08T18:20:26+00:00" - }, - { - "name": "psr/log", - "version": "1.1.4", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "support": { - "source": "https://github.com/php-fig/log/tree/1.1.4" - }, - "time": "2021-05-03T11:20:27+00:00" - }, - { - "name": "symfony/console", - "version": "v5.4.9", - "source": { - "type": "git", - "url": "https://github.com/symfony/console.git", - "reference": "829d5d1bf60b2efeb0887b7436873becc71a45eb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/829d5d1bf60b2efeb0887b7436873becc71a45eb", - "reference": "829d5d1bf60b2efeb0887b7436873becc71a45eb", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php73": "^1.9", - "symfony/polyfill-php80": "^1.16", - "symfony/service-contracts": "^1.1|^2|^3", - "symfony/string": "^5.1|^6.0" - }, - "conflict": { - "psr/log": ">=3", - "symfony/dependency-injection": "<4.4", - "symfony/dotenv": "<5.1", - "symfony/event-dispatcher": "<4.4", - "symfony/lock": "<4.4", - "symfony/process": "<4.4" - }, - "provide": { - "psr/log-implementation": "1.0|2.0" - }, - "require-dev": { - "psr/log": "^1|^2", - "symfony/config": "^4.4|^5.0|^6.0", - "symfony/dependency-injection": "^4.4|^5.0|^6.0", - "symfony/event-dispatcher": "^4.4|^5.0|^6.0", - "symfony/lock": "^4.4|^5.0|^6.0", - "symfony/process": "^4.4|^5.0|^6.0", - "symfony/var-dumper": "^4.4|^5.0|^6.0" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/lock": "", - "symfony/process": "" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Console\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Eases the creation of beautiful and testable command line interfaces", - "homepage": "https://symfony.com", - "keywords": [ - "cli", - "command line", - "console", - "terminal" - ], - "support": { - "source": "https://github.com/symfony/console/tree/v5.4.9" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-05-18T06:17:34+00:00" - }, - { - "name": "symfony/deprecation-contracts", - "version": "v2.5.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "files": [ - "function.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "A generic function and convention to trigger deprecation notices", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.1" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-01-02T09:53:40+00:00" - }, - { - "name": "symfony/event-dispatcher", - "version": "v5.4.9", - "source": { - "type": "git", - "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "8e6ce1cc0279e3ff3c8ff0f43813bc88d21ca1bc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/8e6ce1cc0279e3ff3c8ff0f43813bc88d21ca1bc", - "reference": "8e6ce1cc0279e3ff3c8ff0f43813bc88d21ca1bc", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/event-dispatcher-contracts": "^2|^3", - "symfony/polyfill-php80": "^1.16" - }, - "conflict": { - "symfony/dependency-injection": "<4.4" - }, - "provide": { - "psr/event-dispatcher-implementation": "1.0", - "symfony/event-dispatcher-implementation": "2.0" - }, - "require-dev": { - "psr/log": "^1|^2|^3", - "symfony/config": "^4.4|^5.0|^6.0", - "symfony/dependency-injection": "^4.4|^5.0|^6.0", - "symfony/error-handler": "^4.4|^5.0|^6.0", - "symfony/expression-language": "^4.4|^5.0|^6.0", - "symfony/http-foundation": "^4.4|^5.0|^6.0", - "symfony/service-contracts": "^1.1|^2|^3", - "symfony/stopwatch": "^4.4|^5.0|^6.0" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\EventDispatcher\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v5.4.9" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-05-05T16:45:39+00:00" - }, - { - "name": "symfony/event-dispatcher-contracts", - "version": "v2.5.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "f98b54df6ad059855739db6fcbc2d36995283fe1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/f98b54df6ad059855739db6fcbc2d36995283fe1", - "reference": "f98b54df6ad059855739db6fcbc2d36995283fe1", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "psr/event-dispatcher": "^1" - }, - "suggest": { - "symfony/event-dispatcher-implementation": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Contracts\\EventDispatcher\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Generic abstractions related to dispatching event", - "homepage": "https://symfony.com", - "keywords": [ - "abstractions", - "contracts", - "decoupling", - "interfaces", - "interoperability", - "standards" - ], - "support": { - "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v2.5.1" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-01-02T09:53:40+00:00" - }, - { - "name": "symfony/filesystem", - "version": "v5.4.9", - "source": { - "type": "git", - "url": "https://github.com/symfony/filesystem.git", - "reference": "36a017fa4cce1eff1b8e8129ff53513abcef05ba" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/36a017fa4cce1eff1b8e8129ff53513abcef05ba", - "reference": "36a017fa4cce1eff1b8e8129ff53513abcef05ba", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-mbstring": "~1.8", - "symfony/polyfill-php80": "^1.16" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Filesystem\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides basic utilities for the filesystem", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/filesystem/tree/v5.4.9" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-05-20T13:55:35+00:00" - }, - { - "name": "symfony/finder", - "version": "v5.4.8", - "source": { - "type": "git", - "url": "https://github.com/symfony/finder.git", - "reference": "9b630f3427f3ebe7cd346c277a1408b00249dad9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/9b630f3427f3ebe7cd346c277a1408b00249dad9", - "reference": "9b630f3427f3ebe7cd346c277a1408b00249dad9", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-php80": "^1.16" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Finder\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Finds files and directories via an intuitive fluent interface", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/finder/tree/v5.4.8" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-04-15T08:07:45+00:00" - }, - { - "name": "symfony/options-resolver", - "version": "v5.4.3", - "source": { - "type": "git", - "url": "https://github.com/symfony/options-resolver.git", - "reference": "cc1147cb11af1b43f503ac18f31aa3bec213aba8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/cc1147cb11af1b43f503ac18f31aa3bec213aba8", - "reference": "cc1147cb11af1b43f503ac18f31aa3bec213aba8", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-php73": "~1.0", - "symfony/polyfill-php80": "^1.16" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\OptionsResolver\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides an improved replacement for the array_replace PHP function", - "homepage": "https://symfony.com", - "keywords": [ - "config", - "configuration", - "options" - ], - "support": { - "source": "https://github.com/symfony/options-resolver/tree/v5.4.3" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-01-02T09:53:40+00:00" - }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.26.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4", - "reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "provide": { - "ext-ctype": "*" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.26-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.26.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-05-24T11:49:31+00:00" - }, - { - "name": "symfony/polyfill-intl-grapheme", - "version": "v1.26.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "433d05519ce6990bf3530fba6957499d327395c2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/433d05519ce6990bf3530fba6957499d327395c2", - "reference": "433d05519ce6990bf3530fba6957499d327395c2", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "suggest": { - "ext-intl": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.26-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Intl\\Grapheme\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for intl's grapheme_* functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "grapheme", - "intl", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.26.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-05-24T11:49:31+00:00" - }, - { - "name": "symfony/polyfill-intl-normalizer", - "version": "v1.26.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "219aa369ceff116e673852dce47c3a41794c14bd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/219aa369ceff116e673852dce47c3a41794c14bd", - "reference": "219aa369ceff116e673852dce47c3a41794c14bd", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "suggest": { - "ext-intl": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.26-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Intl\\Normalizer\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for intl's Normalizer class and related functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "intl", - "normalizer", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.26.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-05-24T11:49:31+00:00" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.26.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e", - "reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "provide": { - "ext-mbstring": "*" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.26-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.26.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-05-24T11:49:31+00:00" - }, - { - "name": "symfony/polyfill-php73", - "version": "v1.26.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/e440d35fa0286f77fb45b79a03fedbeda9307e85", - "reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.26-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.26.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-05-24T11:49:31+00:00" - }, - { - "name": "symfony/polyfill-php80", - "version": "v1.26.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/cfa0ae98841b9e461207c13ab093d76b0fa7bace", - "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.26-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.26.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-05-10T07:21:04+00:00" - }, - { - "name": "symfony/polyfill-php81", - "version": "v1.26.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php81.git", - "reference": "13f6d1271c663dc5ae9fb843a8f16521db7687a1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/13f6d1271c663dc5ae9fb843a8f16521db7687a1", - "reference": "13f6d1271c663dc5ae9fb843a8f16521db7687a1", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.26-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php81\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/v1.26.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-05-24T11:49:31+00:00" - }, - { - "name": "symfony/process", - "version": "v5.4.8", - "source": { - "type": "git", - "url": "https://github.com/symfony/process.git", - "reference": "597f3fff8e3e91836bb0bd38f5718b56ddbde2f3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/597f3fff8e3e91836bb0bd38f5718b56ddbde2f3", - "reference": "597f3fff8e3e91836bb0bd38f5718b56ddbde2f3", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/polyfill-php80": "^1.16" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Process\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Executes commands in sub-processes", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/process/tree/v5.4.8" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-04-08T05:07:18+00:00" - }, - { - "name": "symfony/service-contracts", - "version": "v2.5.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/service-contracts.git", - "reference": "24d9dc654b83e91aa59f9d167b131bc3b5bea24c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/24d9dc654b83e91aa59f9d167b131bc3b5bea24c", - "reference": "24d9dc654b83e91aa59f9d167b131bc3b5bea24c", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "psr/container": "^1.1", - "symfony/deprecation-contracts": "^2.1|^3" - }, - "conflict": { - "ext-psr": "<1.1|>=2" - }, - "suggest": { - "symfony/service-implementation": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Contracts\\Service\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Generic abstractions related to writing services", - "homepage": "https://symfony.com", - "keywords": [ - "abstractions", - "contracts", - "decoupling", - "interfaces", - "interoperability", - "standards" - ], - "support": { - "source": "https://github.com/symfony/service-contracts/tree/v2.5.1" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-03-13T20:07:29+00:00" - }, - { - "name": "symfony/stopwatch", - "version": "v5.4.5", - "source": { - "type": "git", - "url": "https://github.com/symfony/stopwatch.git", - "reference": "4d04b5c24f3c9a1a168a131f6cbe297155bc0d30" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/4d04b5c24f3c9a1a168a131f6cbe297155bc0d30", - "reference": "4d04b5c24f3c9a1a168a131f6cbe297155bc0d30", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/service-contracts": "^1|^2|^3" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Stopwatch\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides a way to profile code", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/stopwatch/tree/v5.4.5" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-02-18T16:06:09+00:00" - }, - { - "name": "symfony/string", - "version": "v5.4.9", - "source": { - "type": "git", - "url": "https://github.com/symfony/string.git", - "reference": "985e6a9703ef5ce32ba617c9c7d97873bb7b2a99" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/985e6a9703ef5ce32ba617c9c7d97873bb7b2a99", - "reference": "985e6a9703ef5ce32ba617c9c7d97873bb7b2a99", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-intl-grapheme": "~1.0", - "symfony/polyfill-intl-normalizer": "~1.0", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php80": "~1.15" - }, - "conflict": { - "symfony/translation-contracts": ">=3.0" - }, - "require-dev": { - "symfony/error-handler": "^4.4|^5.0|^6.0", - "symfony/http-client": "^4.4|^5.0|^6.0", - "symfony/translation-contracts": "^1.1|^2", - "symfony/var-exporter": "^4.4|^5.0|^6.0" - }, - "type": "library", - "autoload": { - "files": [ - "Resources/functions.php" - ], - "psr-4": { - "Symfony\\Component\\String\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", - "homepage": "https://symfony.com", - "keywords": [ - "grapheme", - "i18n", - "string", - "unicode", - "utf-8", - "utf8" - ], - "support": { - "source": "https://github.com/symfony/string/tree/v5.4.9" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-04-19T10:40:37+00:00" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": [], - "platform-dev": [], - "plugin-api-version": "2.1.0" -} diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 07b96d6..2f0b252 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -31,6 +31,7 @@ namespace OCA\Files_FullTextSearch\AppInfo; + use OCA\Files_FullTextSearch\Listeners\FileChanged; use OCA\Files_FullTextSearch\Listeners\FileCreated; use OCA\Files_FullTextSearch\Listeners\FileDeleted; @@ -49,8 +50,6 @@ use OCP\Share\Events\ShareDeletedEvent; use Throwable; -require_once __DIR__ . '/../../vendor/autoload.php'; - /** * Class Application diff --git a/lib/Db/CoreQueryBuilder.php b/lib/Db/CoreQueryBuilder.php index 0862f2a..86a5692 100644 --- a/lib/Db/CoreQueryBuilder.php +++ b/lib/Db/CoreQueryBuilder.php @@ -31,7 +31,8 @@ namespace OCA\Files_FullTextSearch\Db; -use ArtificialOwl\MySmallPhpTools\Db\ExtendedQueryBuilder; + +use OCA\Files_FullTextSearch\Tools\Db\ExtendedQueryBuilder; /** * Class CoreQueryBuilder @@ -43,9 +44,9 @@ class CoreQueryBuilder extends ExtendedQueryBuilder { /** * Limit the request to the Id * - * @param $fileSource + * @param int $fileSource */ public function limitToFileSource(int $fileSource) { - $this->limitToDBFieldInt('file_source', $fileSource); + $this->limitInt('file_source', $fileSource); } } diff --git a/lib/Db/CoreRequestBuilder.php b/lib/Db/CoreRequestBuilder.php index 9a79222..71241d7 100644 --- a/lib/Db/CoreRequestBuilder.php +++ b/lib/Db/CoreRequestBuilder.php @@ -31,11 +31,8 @@ namespace OCA\Files_FullTextSearch\Db; -use OC; -use OC\SystemConfig; + use OCA\Files_FullTextSearch\Service\MiscService; -use OCP\IDBConnection; -use Psr\Log\LoggerInterface; /** * Class CoreRequestBuilder @@ -66,10 +63,6 @@ public function __construct(MiscService $miscService) { * @return CoreQueryBuilder */ public function getQueryBuilder(): CoreQueryBuilder { - return new CoreQueryBuilder( - OC::$server->get(IDBConnection::class), - OC::$server->get(SystemConfig::class), - OC::$server->get(LoggerInterface::class) - ); + return new CoreQueryBuilder(); } } diff --git a/lib/Listeners/ListenersCore.php b/lib/Listeners/ListenersCore.php index be19c08..a47f813 100644 --- a/lib/Listeners/ListenersCore.php +++ b/lib/Listeners/ListenersCore.php @@ -31,12 +31,13 @@ namespace OCA\Files_FullTextSearch\Listeners; -use ArtificialOwl\MySmallPhpTools\Traits\Nextcloud\nc21\TNC21Logger; -use ArtificialOwl\MySmallPhpTools\Traits\TArrayTools; + use OC\AppFramework\Bootstrap\Coordinator; use OCA\Files_FullTextSearch\Service\ConfigService; use OCA\Files_FullTextSearch\Service\FilesService; use OCA\Files_FullTextSearch\Service\MiscService; +use OCA\Files_FullTextSearch\Tools\Traits\TArrayTools; +use OCA\Files_FullTextSearch\Tools\Traits\TNCLogger; use OCP\FullTextSearch\IFullTextSearchManager; use OCP\IUserSession; @@ -47,7 +48,7 @@ */ class ListenersCore { use TArrayTools; - use TNC21Logger; + use TNCLogger; /** @var IUserSession */ diff --git a/lib/Provider/FilesProvider.php b/lib/Provider/FilesProvider.php index faa09ab..bcd1cab 100644 --- a/lib/Provider/FilesProvider.php +++ b/lib/Provider/FilesProvider.php @@ -31,7 +31,8 @@ namespace OCA\Files_FullTextSearch\Provider; -use ArtificialOwl\MySmallPhpTools\Traits\Nextcloud\nc22\TNC22Logger; + +use OCA\Files_FullTextSearch\Tools\Traits\TNCLogger; use OC\FullTextSearch\Model\SearchOption; use OC\FullTextSearch\Model\SearchTemplate; use OC\User\NoUserException; @@ -64,7 +65,9 @@ * @package OCA\Files_FullTextSearch\Provider */ class FilesProvider implements IFullTextSearchProvider { - use TNC22Logger; + + + use TNCLogger; public const FILES_PROVIDER_ID = 'files'; diff --git a/lib/Service/ExternalFilesService.php b/lib/Service/ExternalFilesService.php index 0af4a36..339b5d7 100644 --- a/lib/Service/ExternalFilesService.php +++ b/lib/Service/ExternalFilesService.php @@ -31,8 +31,9 @@ namespace OCA\Files_FullTextSearch\Service; -use ArtificialOwl\MySmallPhpTools\Traits\Nextcloud\nc22\TNC22Logger; -use ArtificialOwl\MySmallPhpTools\Traits\TArrayTools; + +use OCA\Files_FullTextSearch\Tools\Traits\TNCLogger; +use OCA\Files_FullTextSearch\Tools\Traits\TArrayTools; use Exception; use OC; use OC\App\AppManager; @@ -60,7 +61,9 @@ * @package OCA\Files_FullTextSearch\Service */ class ExternalFilesService { - use TNC22Logger; + + + use TNCLogger; use TArrayTools; diff --git a/lib/Service/FilesService.php b/lib/Service/FilesService.php index 8962b58..84eab97 100644 --- a/lib/Service/FilesService.php +++ b/lib/Service/FilesService.php @@ -31,8 +31,9 @@ namespace OCA\Files_FullTextSearch\Service; -use ArtificialOwl\MySmallPhpTools\Traits\Nextcloud\nc22\TNC22Logger; -use ArtificialOwl\MySmallPhpTools\Traits\TPathTools; + +use OCA\Files_FullTextSearch\Tools\Traits\TNCLogger; +use OCA\Files_FullTextSearch\Tools\Traits\TPathTools; use Exception; use OC\FullTextSearch\Model\DocumentAccess; use OC\SystemTag\SystemTagManager; @@ -77,7 +78,7 @@ */ class FilesService { use TPathTools; - use TNC22Logger; + use TNCLogger; public const MIMETYPE_TEXT = 'files_text'; diff --git a/lib/Service/GroupFoldersService.php b/lib/Service/GroupFoldersService.php index 0395e16..10dfaaf 100644 --- a/lib/Service/GroupFoldersService.php +++ b/lib/Service/GroupFoldersService.php @@ -31,8 +31,9 @@ namespace OCA\Files_FullTextSearch\Service; -use ArtificialOwl\MySmallPhpTools\Traits\Nextcloud\nc22\TNC22Logger; -use ArtificialOwl\MySmallPhpTools\Traits\TArrayTools; + +use OCA\Files_FullTextSearch\Tools\Traits\TNCLogger; +use OCA\Files_FullTextSearch\Tools\Traits\TArrayTools; use Exception; use OCA\Files_FullTextSearch\AppInfo\Application; use OCA\Files_FullTextSearch\Exceptions\FileIsNotIndexableException; @@ -54,7 +55,9 @@ * @package OCA\Files_FullTextSearch\Service */ class GroupFoldersService { - use TNC22Logger; + + + use TNCLogger; use TArrayTools; diff --git a/lib/Service/SearchService.php b/lib/Service/SearchService.php index 85a1960..c0dc722 100644 --- a/lib/Service/SearchService.php +++ b/lib/Service/SearchService.php @@ -31,7 +31,8 @@ namespace OCA\Files_FullTextSearch\Service; -use ArtificialOwl\MySmallPhpTools\Traits\TPathTools; + +use OCA\Files_FullTextSearch\Tools\Traits\TPathTools; use Exception; use OCA\Files_FullTextSearch\Model\FilesDocument; use OCP\Files\FileInfo; diff --git a/lib/Tools/Db/ExtendedQueryBuilder.php b/lib/Tools/Db/ExtendedQueryBuilder.php new file mode 100644 index 0000000..e00629f --- /dev/null +++ b/lib/Tools/Db/ExtendedQueryBuilder.php @@ -0,0 +1,1135 @@ + + * @copyright 2022 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_FullTextSearch\Tools\Db; + +use DateInterval; +use DateTime; +use Doctrine\DBAL\Query\QueryBuilder as DBALQueryBuilder; +use Exception; +use OC; +use OC\DB\QueryBuilder\QueryBuilder; +use OC\SystemConfig; +use OCA\Files_FullTextSearch\Tools\Exceptions\DateTimeException; +use OCA\Files_FullTextSearch\Tools\Exceptions\InvalidItemException; +use OCA\Files_FullTextSearch\Tools\Exceptions\RowNotFoundException; +use OCA\Files_FullTextSearch\Tools\Traits\TArrayTools; +use OCP\DB\QueryBuilder\ICompositeExpression; +use OCP\DB\QueryBuilder\IQueryBuilder; +use OCP\IDBConnection; +use Psr\Log\LoggerInterface; + +class ExtendedQueryBuilder extends QueryBuilder { + use TArrayTools; + + + /** @var string */ + private $defaultSelectAlias = ''; + + /** @var array */ + private $defaultValues = []; + + + public function __construct() { + parent::__construct( + OC::$server->get(IDBConnection::class), + OC::$server->get(SystemConfig::class), + OC::$server->get(LoggerInterface::class) + ); + } + + + /** + * @param string $alias + * + * @return self + */ + public function setDefaultSelectAlias(string $alias): self { + $this->defaultSelectAlias = $alias; + + return $this; + } + + /** + * @return string + */ + public function getDefaultSelectAlias(): string { + return $this->defaultSelectAlias; + } + + + /** + * @return array + */ + public function getDefaultValues(): array { + return $this->defaultValues; + } + + /** + * @param string $key + * @param string $value + * + * @return $this + */ + public function addDefaultValue(string $key, string $value): self { + $this->defaultValues[$key] = $value; + + return $this; + } + + /** + * @param int $size + * @param int $page + */ + public function paginate(int $size, int $page = 0): void { + if ($page < 0) { + $page = 0; + } + + $this->chunk($page * $size, $size); + } + + /** + * @param int $offset + * @param int $limit + */ + public function chunk(int $offset, int $limit): void { + if ($offset > -1) { + $this->setFirstResult($offset); + } + + if ($limit > 0) { + $this->setMaxResults($limit); + } + } + + + /** + * Limit the request to the Id + * + * @param int $id + */ + public function limitToId(int $id): void { + $this->limitInt('id', $id); + } + + /** + * @param array $ids + */ + public function limitToIds(array $ids): void { + $this->limitArray('id', $ids); + } + + /** + * @param string $id + */ + public function limitToIdString(string $id): void { + $this->limit('id', $id); + } + + /** + * @param string $userId + */ + public function limitToUserId(string $userId): void { + $this->limit('user_id', $userId); + } + + /** + * @param string $uniqueId + */ + public function limitToUniqueId(string $uniqueId): void { + $this->limit('unique_id', $uniqueId); + } + + /** + * @param string $memberId + */ + public function limitToMemberId(string $memberId): void { + $this->limit('member_id', $memberId); + } + + /** + * @param string $status + */ + public function limitToStatus(string $status): void { + $this->limit('status', $status, '', false); + } + + /** + * @param int $type + */ + public function limitToType(int $type): void { + $this->limitInt('type', $type); + } + + /** + * @param string $type + */ + public function limitToTypeString(string $type): void { + $this->limit('type', $type, '', false); + } + + /** + * @param string $token + */ + public function limitToToken(string $token): void { + $this->limit('token', $token); + } + + + /** + * Limit the request to the creation + * + * @param int $delay + * + * @return self + * @throws Exception + */ + public function limitToCreation(int $delay = 0): self { + $date = new DateTime('now'); + $date->sub(new DateInterval('PT' . $delay . 'M')); + + $this->limitToDBFieldDateTime('creation', $date, true); + + return $this; + } + + + /** + * @param string $field + * @param DateTime $date + * @param bool $orNull + */ + public function limitToDBFieldDateTime(string $field, DateTime $date, bool $orNull = false): void { + $expr = $this->expr(); + $pf = ($this->getType() === DBALQueryBuilder::SELECT) ? $this->getDefaultSelectAlias() + . '.' : ''; + $field = $pf . $field; + + $orX = $expr->orX(); + $orX->add( + $expr->lte($field, $this->createNamedParameter($date, IQueryBuilder::PARAM_DATE)) + ); + + if ($orNull === true) { + $orX->add($expr->isNull($field)); + } + + $this->andWhere($orX); + } + + + /** + * @param int $timestamp + * @param string $field + * + * @throws DateTimeException + */ + public function limitToSince(int $timestamp, string $field): void { + try { + $dTime = new DateTime(); + $dTime->setTimestamp($timestamp); + } catch (Exception $e) { + throw new DateTimeException($e->getMessage()); + } + + $expr = $this->expr(); + $pf = ($this->getType() === DBALQueryBuilder::SELECT) ? $this->getDefaultSelectAlias() . '.' : ''; + $field = $pf . $field; + + $orX = $expr->orX(); + $orX->add( + $expr->gte($field, $this->createNamedParameter($dTime, IQueryBuilder::PARAM_DATE)) + ); + + $this->andWhere($orX); + } + + + /** + * @param string $field + * @param string $value + */ + public function searchInDBField(string $field, string $value): void { + $expr = $this->expr(); + + $pf = ($this->getType() === DBALQueryBuilder::SELECT) ? $this->getDefaultSelectAlias() . '.' : ''; + $field = $pf . $field; + + $this->andWhere($expr->iLike($field, $this->createNamedParameter($value))); + } + + + /** + * @param string $field + * @param string $value + * @param string $alias + * @param bool $cs + */ + public function like(string $field, string $value, string $alias = '', bool $cs = true): void { + $this->andWhere($this->exprLike($field, $value, $alias, $cs)); + } + + + /** + * @param string $field + * @param string $value + * @param string $alias + * @param bool $cs + */ + public function limit(string $field, string $value, string $alias = '', bool $cs = true): void { + $this->andWhere($this->exprLimit($field, $value, $alias, $cs)); + } + + /** + * @param string $field + * @param int $value + * @param string $alias + */ + public function limitInt(string $field, int $value, string $alias = ''): void { + $this->andWhere($this->exprLimitInt($field, $value, $alias)); + } + + /** + * @param string $field + * @param bool $value + * @param string $alias + */ + public function limitBool(string $field, bool $value, string $alias = ''): void { + $this->andWhere($this->exprLimitBool($field, $value, $alias)); + } + + /** + * @param string $field + * @param bool $orNull + * @param string $alias + */ + public function limitEmpty(string $field, bool $orNull = false, string $alias = ''): void { + $this->andWhere($this->exprLimitEmpty($field, $orNull, $alias)); + } + + /** + * @param string $field + * @param bool $orEmpty + * @param string $alias + */ + public function limitNull(string $field, bool $orEmpty = false, string $alias = ''): void { + $this->andWhere($this->exprLimitNull($field, $orEmpty, $alias)); + } + + /** + * @param string $field + * @param array $value + * @param string $alias + * @param bool $cs + */ + public function limitArray(string $field, array $value, string $alias = '', bool $cs = true): void { + $this->andWhere($this->exprLimitArray($field, $value, $alias, $cs)); + } + + /** + * @param string $field + * @param array $value + * @param string $alias + */ + public function limitInArray(string $field, array $value, string $alias = ''): void { + $this->andWhere($this->exprLimitInArray($field, $value, $alias)); + } + + /** + * @param string $field + * @param int $flag + * @param string $alias + */ + public function limitBitwise(string $field, int $flag, string $alias = ''): void { + $this->andWhere($this->exprLimitBitwise($field, $flag, $alias)); + } + + /** + * @param string $field + * @param int $value + * @param bool $gte + * @param string $alias + */ + public function gt(string $field, int $value, bool $gte = false, string $alias = ''): void { + $this->andWhere($this->exprGt($field, $value, $gte, $alias)); + } + + /** + * @param string $field + * @param int $value + * @param bool $lte + * @param string $alias + */ + public function lt(string $field, int $value, bool $lte = false, string $alias = ''): void { + $this->andWhere($this->exprLt($field, $value, $lte, $alias)); + } + + + /** + * @param string $field + * @param string $value + * @param string $alias + * @param bool $cs + * + * @return string + */ + public function exprLike(string $field, string $value, string $alias = '', bool $cs = true): string { + if ($this->getType() === DBALQueryBuilder::SELECT) { + $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; + } + + $expr = $this->expr(); + if ($cs) { + return $expr->like($field, $this->createNamedParameter($value)); + } else { + return $expr->iLike($field, $this->createNamedParameter($value)); + } + } + + + /** + * @param string $field + * @param string $value + * @param string $alias + * @param bool $cs + * + * @return string + */ + public function exprLimit(string $field, string $value, string $alias = '', bool $cs = true): string { + if ($this->getType() === DBALQueryBuilder::SELECT) { + $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; + } + + $expr = $this->expr(); + if ($value === '') { + return $expr->emptyString($field); + } + if ($cs) { + return $expr->eq($field, $this->createNamedParameter($value)); + } else { + $func = $this->func(); + + return $expr->eq($func->lower($field), $func->lower($this->createNamedParameter($value))); + } + } + + + /** + * @param string $field + * @param int $value + * @param string $alias + * + * @return string + */ + public function exprLimitInt(string $field, int $value, string $alias = ''): string { + if ($this->getType() === DBALQueryBuilder::SELECT) { + $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; + } + + $expr = $this->expr(); + + return $expr->eq($field, $this->createNamedParameter($value, IQueryBuilder::PARAM_INT)); + } + + + /** + * @param string $field + * @param bool $value + * @param string $alias + * + * @return string + */ + public function exprLimitBool(string $field, bool $value, string $alias = ''): string { + if ($this->getType() === DBALQueryBuilder::SELECT) { + $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; + } + + $expr = $this->expr(); + + return $expr->eq($field, $this->createNamedParameter($value, IQueryBuilder::PARAM_BOOL)); + } + + /** + * @param string $field + * @param bool $orNull + * @param string $alias + * + * @return ICompositeExpression + */ + public function exprLimitEmpty( + string $field, + bool $orNull = false, + string $alias = '' + ): ICompositeExpression { + if ($this->getType() === DBALQueryBuilder::SELECT) { + $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; + } + + $expr = $this->expr(); + $orX = $expr->orX(); + $orX->add($expr->emptyString($field)); + if ($orNull) { + $orX->add($expr->isNull($field)); + } + + return $orX; + } + + /** + * @param string $field + * @param bool $orEmpty + * @param string $alias + * + * @return ICompositeExpression + */ + public function exprLimitNull( + string $field, + bool $orEmpty = false, + string $alias = '' + ): ICompositeExpression { + if ($this->getType() === DBALQueryBuilder::SELECT) { + $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; + } + + $expr = $this->expr(); + $orX = $expr->orX(); + $orX->add($expr->isNull($field)); + if ($orEmpty) { + $orX->add($expr->emptyString($field)); + } + + return $orX; + } + + + /** + * @param string $field + * @param array $values + * @param string $alias + * @param bool $cs + * + * @return ICompositeExpression + */ + public function exprLimitArray( + string $field, + array $values, + string $alias = '', + bool $cs = true + ): ICompositeExpression { + if ($this->getType() === DBALQueryBuilder::SELECT) { + $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; + } + + $andX = $this->expr()->andX(); + foreach ($values as $value) { + if (is_integer($value)) { + $andX->add($this->exprLimitInt($field, $value, $alias)); + } else { + $andX->add($this->exprLimit($field, $value, $alias, $cs)); + } + } + + return $andX; + } + + + /** + * @param string $field + * @param array $values + * @param string $alias + * + * @return string + */ + public function exprLimitInArray(string $field, array $values, string $alias = ''): string { + if ($this->getType() === DBALQueryBuilder::SELECT) { + $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; + } + + $expr = $this->expr(); + + return $expr->in($field, $this->createNamedParameter($values, IQueryBuilder::PARAM_STR_ARRAY)); + } + + + /** + * @param string $field + * @param int $flag + * @param string $alias + * + * @return string + */ + public function exprLimitBitwise(string $field, int $flag, string $alias = ''): string { + if ($this->getType() === DBALQueryBuilder::SELECT) { + $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; + } + + $expr = $this->expr(); + + return $expr->gt( + $expr->bitwiseAnd($field, $flag), + $this->createNamedParameter(0, IQueryBuilder::PARAM_INT) + ); + } + + + /** + * @param string $field + * @param int $value + * @param bool $lte + * @param string $alias + * + * @return string + */ + public function exprLt(string $field, int $value, bool $lte = false, string $alias = ''): string { + if ($this->getType() === DBALQueryBuilder::SELECT) { + $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; + } + + $expr = $this->expr(); + + if ($lte) { + return $expr->lte($field, $this->createNamedParameter($value, IQueryBuilder::PARAM_INT)); + } else { + return $expr->lt($field, $this->createNamedParameter($value, IQueryBuilder::PARAM_INT)); + } + } + + /** + * @param string $field + * @param int $value + * @param bool $gte + * @param string $alias + * + * @return string + */ + public function exprGt(string $field, int $value, bool $gte = false, string $alias = ''): string { + if ($this->getType() === DBALQueryBuilder::SELECT) { + $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; + } + + $expr = $this->expr(); + + if ($gte) { + return $expr->gte($field, $this->createNamedParameter($value, IQueryBuilder::PARAM_INT)); + } else { + return $expr->gt($field, $this->createNamedParameter($value, IQueryBuilder::PARAM_INT)); + } + } + + + /** + * @param string $field + * @param string $value + * @param string $alias + * @param bool $cs + */ + public function unlike(string $field, string $value, string $alias = '', bool $cs = true): void { + $this->andWhere($this->exprUnlike($field, $value, $alias, $cs)); + } + + + /** + * @param string $field + * @param string $value + * @param string $alias + * @param bool $cs + */ + public function filter(string $field, string $value, string $alias = '', bool $cs = true): void { + $this->andWhere($this->exprFilter($field, $value, $alias, $cs)); + } + + /** + * @param string $field + * @param int $value + * @param string $alias + */ + public function filterInt(string $field, int $value, string $alias = ''): void { + $this->andWhere($this->exprFilterInt($field, $value, $alias)); + } + + /** + * @param string $field + * @param bool $value + * @param string $alias + */ + public function filterBool(string $field, bool $value, string $alias = ''): void { + $this->andWhere($this->exprFilterBool($field, $value, $alias)); + } + + /** + * @param string $field + * @param bool $norNull + * @param string $alias + */ + public function filterEmpty(string $field, bool $norNull = false, string $alias = ''): void { + $this->andWhere($this->exprFilterEmpty($field, $norNull, $alias)); + } + + /** + * @param string $field + * @param bool $norEmpty + * @param string $alias + */ + public function filterNull(string $field, bool $norEmpty = false, string $alias = ''): void { + $this->andWhere($this->exprFilterNull($field, $norEmpty, $alias)); + } + + /** + * @param string $field + * @param array $value + * @param string $alias + * @param bool $cs + */ + public function filterArray(string $field, array $value, string $alias = '', bool $cs = true): void { + $this->andWhere($this->exprFilterArray($field, $value, $alias, $cs)); + } + + /** + * @param string $field + * @param array $value + * @param string $alias + */ + public function filterInArray(string $field, array $value, string $alias = ''): void { + $this->andWhere($this->exprFilterInArray($field, $value, $alias)); + } + + /** + * @param string $field + * @param int $flag + * @param string $alias + */ + public function filterBitwise(string $field, int $flag, string $alias = ''): void { + $this->andWhere($this->exprFilterBitwise($field, $flag, $alias)); + } + + + /** + * @param string $field + * @param string $value + * @param string $alias + * @param bool $cs + * + * @return string + */ + public function exprUnlike(string $field, string $value, string $alias = '', bool $cs = true): string { + if ($this->getType() === DBALQueryBuilder::SELECT) { + $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; + } + + $expr = $this->expr(); + if ($cs) { + return $expr->notLike($field, $this->createNamedParameter($value)); + } else { + $func = $this->func(); + + return $expr->notLike($func->lower($field), $func->lower($this->createNamedParameter($value))); + } + } + + + /** + * @param string $field + * @param string $value + * @param string $alias + * @param bool $cs + * + * @return string + */ + public function exprFilter(string $field, string $value, string $alias = '', bool $cs = true): string { + if ($this->getType() === DBALQueryBuilder::SELECT) { + $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; + } + + $expr = $this->expr(); + if ($value === '') { + return $expr->nonEmptyString($field); + } + if ($cs) { + return $expr->neq($field, $this->createNamedParameter($value)); + } else { + $func = $this->func(); + + return $expr->neq($func->lower($field), $func->lower($this->createNamedParameter($value))); + } + } + + + /** + * @param string $field + * @param int $value + * @param string $alias + * + * @return string + */ + public function exprFilterInt(string $field, int $value, string $alias = ''): string { + if ($this->getType() === DBALQueryBuilder::SELECT) { + $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; + } + + $expr = $this->expr(); + + return $expr->neq($field, $this->createNamedParameter($value, IQueryBuilder::PARAM_INT)); + } + + + /** + * @param string $field + * @param bool $value + * @param string $alias + * + * @return string + */ + public function exprFilterBool(string $field, bool $value, string $alias = ''): string { + if ($this->getType() === DBALQueryBuilder::SELECT) { + $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; + } + + $expr = $this->expr(); + + return $expr->neq($field, $this->createNamedParameter($value, IQueryBuilder::PARAM_BOOL)); + } + + /** + * @param string $field + * @param bool $norNull + * @param string $alias + * + * @return ICompositeExpression + */ + public function exprFilterEmpty( + string $field, + bool $norNull = false, + string $alias = '' + ): ICompositeExpression { + if ($this->getType() === DBALQueryBuilder::SELECT) { + $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; + } + + $expr = $this->expr(); + $andX = $expr->andX(); + $andX->add($expr->nonEmptyString($field)); + if ($norNull) { + $andX->add($expr->isNotNull($field)); + } + + return $andX; + } + + /** + * @param string $field + * @param bool $norEmpty + * @param string $alias + * + * @return ICompositeExpression + */ + public function exprFilterNull( + string $field, + bool $norEmpty = false, + string $alias = '' + ): ICompositeExpression { + if ($this->getType() === DBALQueryBuilder::SELECT) { + $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; + } + + $expr = $this->expr(); + $andX = $expr->andX(); + $andX->add($expr->isNotNull($field)); + if ($norEmpty) { + $andX->add($expr->nonEmptyString($field)); + } + + return $andX; + } + + + /** + * @param string $field + * @param array $values + * @param string $alias + * @param bool $cs + * + * @return ICompositeExpression + */ + public function exprFilterArray( + string $field, + array $values, + string $alias = '', + bool $cs = true + ): ICompositeExpression { + if ($this->getType() === DBALQueryBuilder::SELECT) { + $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; + } + + $orX = $this->expr()->orX(); + foreach ($values as $value) { + if (is_integer($value)) { + $orX->add($this->exprFilterInt($field, $value, $alias)); + } else { + $orX->add($this->exprFilter($field, $value, $alias, $cs)); + } + } + + return $orX; + } + + + /** + * @param string $field + * @param array $values + * @param string $alias + * + * @return string + */ + public function exprFilterInArray(string $field, array $values, string $alias = ''): string { + if ($this->getType() === DBALQueryBuilder::SELECT) { + $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; + } + + $expr = $this->expr(); + + return $expr->notIn($field, $this->createNamedParameter($values, IQueryBuilder::PARAM_STR_ARRAY)); + } + + + /** + * @param string $field + * @param int $flag + * @param string $alias + * + * @return string + */ + public function exprFilterBitwise(string $field, int $flag, string $alias = ''): string { + if ($this->getType() === DBALQueryBuilder::SELECT) { + $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; + } + + $expr = $this->expr(); + + return $expr->eq( + $expr->bitwiseAnd($field, $flag), + $this->createNamedParameter(0, IQueryBuilder::PARAM_INT) + ); + } + + + /** + * @param string $object + * @param array $params + * + * @return IQueryRow + * @throws RowNotFoundException + * @throws InvalidItemException + */ + public function asItem(string $object, array $params = []): IQueryRow { + return $this->getRow([$this, 'parseSimpleSelectSql'], $object, $params); + } + + /** + * @param string $object + * @param array $params + * + * @return IQueryRow[] + */ + public function asItems(string $object, array $params = []): array { + return $this->getRows([$this, 'parseSimpleSelectSql'], $object, $params); + } + + + /** + * @param string $field + * @param array $params + * + * @return IQueryRow + * @throws InvalidItemException + * @throws RowNotFoundException + */ + public function asItemFromField(string $field, array $params = []): IQueryRow { + $param['modelFromField'] = $field; + + return $this->getRow([$this, 'parseSimpleSelectSql'], '', $params); + } + + /** + * @param string $field + * @param array $params + * + * @return IQueryRow[] + */ + public function asItemsFromField(string $field, array $params = []): array { + $param['modelFromField'] = $field; + + return $this->getRows([$this, 'parseSimpleSelectSql'], $field, $params); + } + + + /** + * @param array $data + * @param ExtendedQueryBuilder $qb + * @param string $object + * @param array $params + * + * @return IQueryRow + * @throws InvalidItemException + */ + private function parseSimpleSelectSql( + array $data, + ExtendedQueryBuilder $qb, + string $object, + array $params + ): IQueryRow { + $fromField = $this->get('modelFromField', $params); + if ($fromField !== '') { + $object = $fromField; + } + + $item = new $object(); + if (!($item instanceof IQueryRow)) { + throw new InvalidItemException(); + } + + if (!empty($params)) { + $data['_params'] = $params; + } + + foreach ($qb->getDefaultValues() as $k => $v) { + if ($this->get($k, $data) === '') { + $data[$k] = $v; + } + } + + $data = array_merge($qb->getDefaultValues(), $data); + + $item->importFromDatabase($data); + + return $item; + } + + + /** + * @param callable $method + * @param string $object + * @param array $params + * + * @return IQueryRow + * @throws RowNotFoundException + */ + public function getRow(callable $method, string $object = '', array $params = []): IQueryRow { + $cursor = $this->execute(); + $data = $cursor->fetch(); + $cursor->closeCursor(); + + if ($data === false) { + throw new RowNotFoundException(); + } + + return $method($data, $this, $object, $params); + } + + + /** + * @param callable $method + * @param string $object + * @param array $params + * + * @return IQueryRow[] + */ + public function getRows(callable $method, string $object = '', array $params = []): array { + $rows = []; + $cursor = $this->execute(); + while ($data = $cursor->fetch()) { + try { + $rows[] = $method($data, $this, $object, $params); + } catch (Exception $e) { + } + } + $cursor->closeCursor(); + + return $rows; + } + + + /** + * @param string $table + * @param array $fields + * @param string $alias + * + * @return $this + */ + public function generateSelect( + string $table, + array $fields, + string $alias = '' + ): self { + $selectFields = array_map( + function (string $item) use ($alias) { + if ($alias === '') { + return $item; + } + + return $alias . '.' . $item; + }, $fields + ); + + $this->select($selectFields) + ->from($table, $alias) + ->setDefaultSelectAlias($alias); + + return $this; + } + + + /** + * @param array $fields + * @param string $alias + * @param string $prefix + * @param array $default + * + * @return $this + */ + public function generateSelectAlias( + array $fields, + string $alias, + string $prefix, + array $default = [] + ): self { + $prefix = trim($prefix) . '_'; + foreach ($default as $k => $v) { + $this->addDefaultValue($prefix . $k, (string)$v); + } + + foreach ($fields as $field) { + $this->selectAlias($alias . '.' . $field, $prefix . $field); + } + + return $this; + } +} diff --git a/lib/Tools/Db/IQueryRow.php b/lib/Tools/Db/IQueryRow.php new file mode 100644 index 0000000..c3ea6a8 --- /dev/null +++ b/lib/Tools/Db/IQueryRow.php @@ -0,0 +1,49 @@ + + * @copyright 2022 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_FullTextSearch\Tools\Db; + +/** + * Interface IQueryRow + * + * @package OCA\Files_FullTextSearch\Tools\Db + */ +interface IQueryRow { + + /** + * import data to feed the model. + * + * @param array $data + * + * @return IQueryRow + */ + public function importFromDatabase(array $data): self; +} diff --git a/lib/Tools/Exceptions/ArrayNotFoundException.php b/lib/Tools/Exceptions/ArrayNotFoundException.php new file mode 100644 index 0000000..19e1885 --- /dev/null +++ b/lib/Tools/Exceptions/ArrayNotFoundException.php @@ -0,0 +1,42 @@ + + * @copyright 2022 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_FullTextSearch\Tools\Exceptions; + +use Exception; + +/** + * Class ArrayNotFoundException + * + * @package OCA\Files_FullTextSearch\Tools\Exceptions + */ +class ArrayNotFoundException extends Exception { +} diff --git a/lib/Tools/Exceptions/DateTimeException.php b/lib/Tools/Exceptions/DateTimeException.php new file mode 100644 index 0000000..54931a4 --- /dev/null +++ b/lib/Tools/Exceptions/DateTimeException.php @@ -0,0 +1,42 @@ + + * @copyright 2022 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_FullTextSearch\Tools\Exceptions; + +use Exception; + +/** + * Class DateTimeException + * + * @package OCA\Files_FullTextSearch\Tools\Exceptions + */ +class DateTimeException extends Exception { +} diff --git a/lib/Tools/Exceptions/InvalidItemException.php b/lib/Tools/Exceptions/InvalidItemException.php new file mode 100644 index 0000000..4103a78 --- /dev/null +++ b/lib/Tools/Exceptions/InvalidItemException.php @@ -0,0 +1,42 @@ + + * @copyright 2022 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_FullTextSearch\Tools\Exceptions; + +use Exception; + +/** + * Class InvalidItemException + * + * @package OCA\Files_FullTextSearch\Tools\Exceptions + */ +class InvalidItemException extends Exception { +} diff --git a/lib/Tools/Exceptions/InvalidOriginException.php b/lib/Tools/Exceptions/InvalidOriginException.php new file mode 100644 index 0000000..fd32c3a --- /dev/null +++ b/lib/Tools/Exceptions/InvalidOriginException.php @@ -0,0 +1,42 @@ + + * @copyright 2022 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_FullTextSearch\Tools\Exceptions; + +use Exception; + +/** + * Class InvalidOriginException + * + * @package OCA\Files_FullTextSearch\Tools\Exceptions + */ +class InvalidOriginException extends Exception { +} diff --git a/lib/Tools/Exceptions/ItemNotFoundException.php b/lib/Tools/Exceptions/ItemNotFoundException.php new file mode 100644 index 0000000..01c71b0 --- /dev/null +++ b/lib/Tools/Exceptions/ItemNotFoundException.php @@ -0,0 +1,42 @@ + + * @copyright 2022 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_FullTextSearch\Tools\Exceptions; + +use Exception; + +/** + * Class ItemNotFoundException + * + * @package OCA\Files_FullTextSearch\Tools\Exceptions + */ +class ItemNotFoundException extends Exception { +} diff --git a/lib/Tools/Exceptions/MalformedArrayException.php b/lib/Tools/Exceptions/MalformedArrayException.php new file mode 100644 index 0000000..266872a --- /dev/null +++ b/lib/Tools/Exceptions/MalformedArrayException.php @@ -0,0 +1,42 @@ + + * @copyright 2022 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_FullTextSearch\Tools\Exceptions; + +use Exception; + +/** + * Class MalformedArrayException + * + * @package OCA\Files_FullTextSearch\Tools\Exceptions + */ +class MalformedArrayException extends Exception { +} diff --git a/lib/Tools/Exceptions/RequestContentException.php b/lib/Tools/Exceptions/RequestContentException.php new file mode 100644 index 0000000..f0560d7 --- /dev/null +++ b/lib/Tools/Exceptions/RequestContentException.php @@ -0,0 +1,42 @@ + + * @copyright 2022 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_FullTextSearch\Tools\Exceptions; + +use Exception; + +/** + * Class RequestContentException + * + * @package OCA\Files_FullTextSearch\Tools\Exceptions + */ +class RequestContentException extends Exception { +} diff --git a/lib/Tools/Exceptions/RequestNetworkException.php b/lib/Tools/Exceptions/RequestNetworkException.php new file mode 100644 index 0000000..4ec3b7b --- /dev/null +++ b/lib/Tools/Exceptions/RequestNetworkException.php @@ -0,0 +1,42 @@ + + * @copyright 2022 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_FullTextSearch\Tools\Exceptions; + +use Exception; + +/** + * Class RequestNetworkException + * + * @package OCA\Files_FullTextSearch\Tools\Exceptions + */ +class RequestNetworkException extends Exception { +} diff --git a/lib/Tools/Exceptions/RequestResultNotJsonException.php b/lib/Tools/Exceptions/RequestResultNotJsonException.php new file mode 100644 index 0000000..78f7e4e --- /dev/null +++ b/lib/Tools/Exceptions/RequestResultNotJsonException.php @@ -0,0 +1,42 @@ + + * @copyright 2022 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_FullTextSearch\Tools\Exceptions; + +use Exception; + +/** + * Class RequestResultNotJsonException + * + * @package OCA\Files_FullTextSearch\Tools\Exceptions + */ +class RequestResultNotJsonException extends Exception { +} diff --git a/lib/Tools/Exceptions/RequestResultSizeException.php b/lib/Tools/Exceptions/RequestResultSizeException.php new file mode 100644 index 0000000..2fceb4c --- /dev/null +++ b/lib/Tools/Exceptions/RequestResultSizeException.php @@ -0,0 +1,42 @@ + + * @copyright 2022 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_FullTextSearch\Tools\Exceptions; + +use Exception; + +/** + * Class RequestResultSizeException + * + * @package OCA\Files_FullTextSearch\Tools\Exceptions + */ +class RequestResultSizeException extends Exception { +} diff --git a/lib/Tools/Exceptions/RequestServerException.php b/lib/Tools/Exceptions/RequestServerException.php new file mode 100644 index 0000000..8b6e008 --- /dev/null +++ b/lib/Tools/Exceptions/RequestServerException.php @@ -0,0 +1,42 @@ + + * @copyright 2022 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_FullTextSearch\Tools\Exceptions; + +use Exception; + +/** + * Class RequestServerException + * + * @package OCA\Files_FullTextSearch\Tools\Exceptions + */ +class RequestServerException extends Exception { +} diff --git a/lib/Tools/Exceptions/RowNotFoundException.php b/lib/Tools/Exceptions/RowNotFoundException.php new file mode 100644 index 0000000..93c7ceb --- /dev/null +++ b/lib/Tools/Exceptions/RowNotFoundException.php @@ -0,0 +1,42 @@ + + * @copyright 2022 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_FullTextSearch\Tools\Exceptions; + +use Exception; + +/** + * Class RowNotFoundException + * + * @package OCA\Files_FullTextSearch\Tools\Exceptions + */ +class RowNotFoundException extends Exception { +} diff --git a/lib/Tools/Exceptions/SignatoryException.php b/lib/Tools/Exceptions/SignatoryException.php new file mode 100644 index 0000000..32ee1cf --- /dev/null +++ b/lib/Tools/Exceptions/SignatoryException.php @@ -0,0 +1,42 @@ + + * @copyright 2022 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_FullTextSearch\Tools\Exceptions; + +use Exception; + +/** + * Class SignatoryException + * + * @package OCA\Files_FullTextSearch\Tools\Exceptions + */ +class SignatoryException extends Exception { +} diff --git a/lib/Tools/Exceptions/SignatureException.php b/lib/Tools/Exceptions/SignatureException.php new file mode 100644 index 0000000..976b2f3 --- /dev/null +++ b/lib/Tools/Exceptions/SignatureException.php @@ -0,0 +1,42 @@ + + * @copyright 2022 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_FullTextSearch\Tools\Exceptions; + +use Exception; + +/** + * Class SignatureException + * + * @package OCA\Files_FullTextSearch\Tools\Exceptions + */ +class SignatureException extends Exception { +} diff --git a/lib/Tools/Exceptions/UnknownTypeException.php b/lib/Tools/Exceptions/UnknownTypeException.php new file mode 100644 index 0000000..0890f5d --- /dev/null +++ b/lib/Tools/Exceptions/UnknownTypeException.php @@ -0,0 +1,42 @@ + + * @copyright 2022 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_FullTextSearch\Tools\Exceptions; + +use Exception; + +/** + * Class UnknownTypeException + * + * @package OCA\Files_FullTextSearch\Tools\Exceptions + */ +class UnknownTypeException extends Exception { +} diff --git a/lib/Tools/Exceptions/WellKnownLinkNotFoundException.php b/lib/Tools/Exceptions/WellKnownLinkNotFoundException.php new file mode 100644 index 0000000..8658ddd --- /dev/null +++ b/lib/Tools/Exceptions/WellKnownLinkNotFoundException.php @@ -0,0 +1,42 @@ + + * @copyright 2022 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_FullTextSearch\Tools\Exceptions; + +use Exception; + +/** + * Class WellKnownLinkNotFoundException + * + * @package OCA\Files_FullTextSearch\Tools\Exceptions + */ +class WellKnownLinkNotFoundException extends Exception { +} diff --git a/lib/Tools/IDeserializable.php b/lib/Tools/IDeserializable.php new file mode 100644 index 0000000..0cc77bc --- /dev/null +++ b/lib/Tools/IDeserializable.php @@ -0,0 +1,42 @@ + + * @copyright 2022 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_FullTextSearch\Tools; + +interface IDeserializable { + + /** + * @param array $data + * + * @return self + */ + public function import(array $data): self; +} diff --git a/lib/Tools/Traits/TArrayTools.php b/lib/Tools/Traits/TArrayTools.php new file mode 100644 index 0000000..cd52ceb --- /dev/null +++ b/lib/Tools/Traits/TArrayTools.php @@ -0,0 +1,432 @@ + + * @copyright 2022 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_FullTextSearch\Tools\Traits; + +use Exception; +use JsonSerializable; +use OCA\Files_FullTextSearch\Tools\Exceptions\ArrayNotFoundException; +use OCA\Files_FullTextSearch\Tools\Exceptions\ItemNotFoundException; +use OCA\Files_FullTextSearch\Tools\Exceptions\MalformedArrayException; +use OCA\Files_FullTextSearch\Tools\Exceptions\UnknownTypeException; + +trait TArrayTools { + public static $TYPE_NULL = 'Null'; + public static $TYPE_STRING = 'String'; + public static $TYPE_ARRAY = 'Array'; + public static $TYPE_BOOLEAN = 'Boolean'; + public static $TYPE_INTEGER = 'Integer'; + public static $TYPE_SERIALIZABLE = 'Serializable'; + + + /** + * @param string $k + * @param array $arr + * @param string $default + * + * @return string + */ + protected function get(string $k, array $arr, string $default = ''): string { + if (!array_key_exists($k, $arr)) { + $subs = explode('.', $k, 2); + if (sizeof($subs) > 1) { + if (!array_key_exists($subs[0], $arr)) { + return $default; + } + + $r = $arr[$subs[0]]; + if (!is_array($r)) { + return $default; + } + + return $this->get($subs[1], $r, $default); + } else { + return $default; + } + } + + if ($arr[$k] === null || !is_string($arr[$k]) && (!is_int($arr[$k]))) { + return $default; + } + + return (string)$arr[$k]; + } + + + /** + * @param string $k + * @param array $arr + * @param int $default + * + * @return int + */ + protected function getInt(string $k, array $arr, int $default = 0): int { + if (!array_key_exists($k, $arr)) { + $subs = explode('.', $k, 2); + if (sizeof($subs) > 1) { + if (!array_key_exists($subs[0], $arr)) { + return $default; + } + + $r = $arr[$subs[0]]; + if (!is_array($r)) { + return $default; + } + + return $this->getInt($subs[1], $r, $default); + } else { + return $default; + } + } + + if ($arr[$k] === null) { + return $default; + } + + return intval($arr[$k]); + } + + + /** + * @param string $k + * @param array $arr + * @param float $default + * + * @return float + */ + protected function getFloat(string $k, array $arr, float $default = 0): float { + if (!array_key_exists($k, $arr)) { + $subs = explode('.', $k, 2); + if (sizeof($subs) > 1) { + if (!array_key_exists($subs[0], $arr)) { + return $default; + } + + $r = $arr[$subs[0]]; + if (!is_array($r)) { + return $default; + } + + return $this->getFloat($subs[1], $r, $default); + } else { + return $default; + } + } + + if ($arr[$k] === null) { + return $default; + } + + return intval($arr[$k]); + } + + + /** + * @param string $k + * @param array $arr + * @param bool $default + * + * @return bool + */ + protected function getBool(string $k, array $arr, bool $default = false): bool { + if (!array_key_exists($k, $arr)) { + $subs = explode('.', $k, 2); + if (sizeof($subs) > 1) { + if (!array_key_exists($subs[0], $arr)) { + return $default; + } + + return $this->getBool($subs[1], $arr[$subs[0]], $default); + } else { + return $default; + } + } + + if ($arr[$k] === null) { + return $default; + } + + if (is_bool($arr[$k])) { + return $arr[$k]; + } + + $sk = (string)$arr[$k]; + if ($sk === '1' || strtolower($sk) === 'true') { + return true; + } + + if ($sk === '0' || strtolower($sk) === 'false') { + return false; + } + + return $default; + } + + + /** + * @param string $k + * @param array $arr + * @param JsonSerializable|null $default + * + * @return mixed + */ + protected function getObj(string $k, array $arr, ?JsonSerializable $default = null): ?JsonSerializable { + if (!array_key_exists($k, $arr)) { + $subs = explode('.', $k, 2); + if (sizeof($subs) > 1) { + if (!array_key_exists($subs[0], $arr)) { + return $default; + } + + return $this->getObj($subs[1], $arr[$subs[0]], $default); + } else { + return $default; + } + } + + return $arr[$k]; + } + + + /** + * @param string $k + * @param array $arr + * @param array $default + * + * @return array + */ + protected function getArray(string $k, array $arr, array $default = []): array { + if (!array_key_exists($k, $arr)) { + $subs = explode('.', $k, 2); + if (sizeof($subs) > 1) { + if (!array_key_exists($subs[0], $arr)) { + return $default; + } + + $r = $arr[$subs[0]]; + if (!is_array($r)) { + return $default; + } + + return $this->getArray($subs[1], $r, $default); + } else { + return $default; + } + } + + $r = $arr[$k]; + if (!is_array($r) && !is_string($r)) { + return $default; + } + + if (is_string($r)) { + $r = json_decode($r, true); + } + + if (!is_array($r)) { + return $default; + } + + return $r; + } + + + /** + * @param string $k + * @param array $arr + * + * @return bool + */ + public function validKey(string $k, array $arr): bool { + if (array_key_exists($k, $arr)) { + return true; + } + + $subs = explode('.', $k, 2); + if (sizeof($subs) > 1) { + if (!array_key_exists($subs[0], $arr)) { + return false; + } + + $r = $arr[$subs[0]]; + if (!is_array($r)) { + return false; + } + + return $this->validKey($subs[1], $r); + } + + return false; + } + + + /** + * @param string $k + * @param array $arr + * @param array $import + * @param array $default + * + * @return array + */ + protected function getList(string $k, array $arr, array $import, array $default = []): array { + $list = $this->getArray($k, $arr, $default); + + $r = []; + [$obj, $method] = $import; + foreach ($list as $item) { + try { + $o = new $obj(); + $o->$method($item); + + $r[] = $o; + } catch (Exception $e) { + } + } + + return $r; + } + + + /** + * @param string $k + * @param string $value + * @param array $list + * + * @return mixed + * @throws ArrayNotFoundException + */ + protected function extractArray(string $k, string $value, array $list) { + foreach ($list as $arr) { + if (!array_key_exists($k, $arr)) { + continue; + } + + if ($arr[$k] === $value) { + return $arr; + } + } + + throw new ArrayNotFoundException(); + } + + + /** + * @param string $key + * @param array $arr + * @param bool $root + * + * @return string + * @throws ItemNotFoundException + * @throws UnknownTypeException + */ + public function typeOf(string $key, array $arr, bool $root = true): string { + if (array_key_exists($key, $arr)) { + $item = $arr[$key]; + + if (is_null($item)) { + return self::$TYPE_NULL; + } + + if (is_string($item)) { + return self::$TYPE_STRING; + } + + if (is_array($item)) { + return self::$TYPE_ARRAY; + } + + if (is_bool($item)) { + return self::$TYPE_BOOLEAN; + } + + if (is_int($item)) { + return self::$TYPE_INTEGER; + } + + if ($item instanceof JsonSerializable) { + return self::$TYPE_SERIALIZABLE; + } + + throw new UnknownTypeException(); + } + + $subs = explode('.', $key, 2); + if (sizeof($subs) > 1) { + if (!array_key_exists($subs[0], $arr)) { + throw new ItemNotFoundException(); + } + + $r = $arr[$subs[0]]; + if (is_array($r)) { + return $this->typeOf($subs[1], $r); + } + } + + throw new ItemNotFoundException(); + } + + + /** + * @param array $keys + * @param array $arr + * + * @throws MalformedArrayException + */ + protected function mustContains(array $keys, array $arr) { + foreach ($keys as $key) { + if (!array_key_exists($key, $arr)) { + throw new MalformedArrayException( + 'source: ' . json_encode($arr) . ' - missing key: ' . $key + ); + } + } + } + + + /** + * @param array $arr + */ + protected function cleanArray(array &$arr) { + $arr = array_filter( + $arr, + function ($v) { + if (is_string($v)) { + return ($v !== ''); + } + if (is_array($v)) { + return !empty($v); + } + + return true; + } + ); + } +} diff --git a/lib/Tools/Traits/TNCLogger.php b/lib/Tools/Traits/TNCLogger.php new file mode 100644 index 0000000..20ff04a --- /dev/null +++ b/lib/Tools/Traits/TNCLogger.php @@ -0,0 +1,201 @@ + + * @copyright 2022 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_FullTextSearch\Tools\Traits; + +use Exception; +use OC; +use OC\HintException; +use Psr\Log\LoggerInterface; +use Throwable; + +trait TNCLogger { + use TNCSetup; + + + public static $EMERGENCY = 4; + public static $ALERT = 3; + public static $CRITICAL = 3; + public static $ERROR = 3; + public static $WARNING = 2; + public static $NOTICE = 1; + public static $INFO = 1; + public static $DEBUG = 0; + + + /** + * @param Throwable $t + * @param array $serializable + */ + public function t(Throwable $t, array $serializable = []): void { + $this->throwable($t, self::$ERROR, $serializable); + } + + /** + * @param Throwable $t + * @param int $level + * @param array $serializable + */ + public function throwable(Throwable $t, int $level = 3, array $serializable = []): void { + $message = ''; + if (!empty($serializable)) { + $message = json_encode($serializable); + } + + $this->logger() + ->log( + $level, + $message, + [ + 'app' => $this->setup('app'), + 'exception' => $t + ] + ); + } + + + /** + * @param Exception $e + * @param array $serializable + */ + public function e(Exception $e, array $serializable = []): void { + $this->exception($e, self::$ERROR, $serializable); + } + + /** + * @param Exception $e + * @param int|array $level + * @param array $serializable + */ + public function exception(Exception $e, $level = 3, array $serializable = []): void { + if (is_array($level) && empty($serializable)) { + $serializable = $level; + $level = 3; + } + + $message = ''; + if (!empty($serializable)) { + $message = json_encode($serializable); + } + + if ($level === self::$DEBUG) { + $level = (int)$this->appConfig('debug_level'); + } + + $this->logger() + ->log( + $level, + $message, + [ + 'app' => $this->setup('app'), + 'exception' => $e + ] + ); + } + + + /** + * @param string $message + * @param bool $trace + * @param array $serializable + */ + public function emergency(string $message, bool $trace = false, array $serializable = []): void { + $this->log(self::$EMERGENCY, '[emergency] ' . $message, $trace, $serializable); + } + + /** + * @param string $message + * @param bool $trace + * @param array $serializable + */ + public function alert(string $message, bool $trace = false, array $serializable = []): void { + $this->log(self::$ALERT, '[alert] ' . $message, $trace, $serializable); + } + + /** + * @param string $message + * @param bool $trace + * @param array $serializable + */ + public function warning(string $message, bool $trace = false, array $serializable = []): void { + $this->log(self::$WARNING, '[warning] ' . $message, $trace, $serializable); + } + + /** + * @param string $message + * @param bool $trace + * @param array $serializable + */ + public function notice(string $message, bool $trace = false, array $serializable = []): void { + $this->log(self::$NOTICE, '[notice] ' . $message, $trace, $serializable); + } + + /** + * @param string $message + * @param array $serializable + */ + public function debug(string $message, array $serializable = []): void { + $message = '[debug] ' . $message; + $debugLevel = (int)$this->appConfig('debug_level'); + $this->log($debugLevel, $message, ($this->appConfig('debug_trace') === '1'), $serializable); + } + + + /** + * @param int $level + * @param string $message + * @param bool $trace + * @param array $serializable + */ + public function log(int $level, string $message, bool $trace = false, array $serializable = []): void { + $opts = ['app' => $this->setup('app')]; + if ($trace) { + $opts['exception'] = new HintException($message, json_encode($serializable)); + } elseif (!empty($serializable)) { + $message .= ' -- ' . json_encode($serializable); + } + + $this->logger() + ->log($level, $message, $opts); + } + + + /** + * @return LoggerInterface + */ + public function logger(): LoggerInterface { + if (isset($this->logger) && $this->logger instanceof LoggerInterface) { + return $this->logger; + } else { + return OC::$server->get(LoggerInterface::class); + } + } +} diff --git a/lib/Tools/Traits/TNCSetup.php b/lib/Tools/Traits/TNCSetup.php new file mode 100644 index 0000000..1795133 --- /dev/null +++ b/lib/Tools/Traits/TNCSetup.php @@ -0,0 +1,107 @@ + + * @copyright 2022 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_FullTextSearch\Tools\Traits; + +use OC; +use OCP\IConfig; + +trait TNCSetup { + use TArrayTools; + + + /** @var array */ + private $_setup = []; + + + /** + * @param string $key + * @param string $value + * + * @param string $default + * + * @return string + */ + public function setup(string $key, string $value = '', string $default = ''): string { + if ($value !== '') { + $this->_setup[$key] = $value; + } + + return $this->get($key, $this->_setup, $default); + } + + /** + * @param string $key + * @param array $value + * @param array $default + * + * @return array + */ + public function setupArray(string $key, array $value = [], array $default = []): array { + if (!empty($value)) { + $this->_setup[$key] = $value; + } + + return $this->getArray($key, $this->_setup, $default); + } + + /** + * @param string $key + * @param int $value + * @param int $default + * + * @return int + */ + public function setupInt(string $key, int $value = -999, int $default = 0): int { + if ($value !== -999) { + $this->_setup[$key] = $value; + } + + return $this->getInt($key, $this->_setup, $default); + } + + /** + * @param string $key + * + * @return string + */ + public function appConfig(string $key): string { + $app = $this->setup('app'); + if ($app === '') { + return ''; + } + + /** @var IConfig $config */ + $config = OC::$server->get(IConfig::class); + + return $config->getAppValue($app, $key, ''); + } +} diff --git a/lib/Tools/Traits/TStringTools.php b/lib/Tools/Traits/TStringTools.php new file mode 100644 index 0000000..433b0f8 --- /dev/null +++ b/lib/Tools/Traits/TStringTools.php @@ -0,0 +1,258 @@ + + * @copyright 2022 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_FullTextSearch\Tools\Traits; + +use DateTime; +use Exception; + +trait TStringTools { + use TArrayTools; + + + /** + * @param int $length + * + * @return string + */ + protected function token(int $length = 15): string { + $chars = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890'; + + $str = ''; + $max = strlen($chars); + for ($i = 0; $i < $length; $i++) { + try { + $str .= $chars[random_int(0, $max - 2)]; + } catch (Exception $e) { + } + } + + return $str; + } + + + /** + * Generate uuid: 2b5a7a87-8db1-445f-a17b-405790f91c80 + * + * @param int $length + * + * @return string + */ + protected function uuid(int $length = 0): string { + $uuid = sprintf( + '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), + mt_rand(0, 0xffff), mt_rand(0, 0xfff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, + mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) + ); + + if ($length > 0) { + if ($length <= 16) { + $uuid = str_replace('-', '', $uuid); + } + + $uuid = substr($uuid, 0, $length); + } + + return $uuid; + } + + + /** + * @param string $line + * @param int $length + * + * @return string + */ + protected function cut(string $line, int $length): string { + if (strlen($line) < $length) { + return $line; + } + + return substr($line, 0, $length - 5) . ' (..)'; + } + + /** + * @param string $str1 + * @param string $str2 + * @param bool $cs case sensitive ? + * + * @return string + */ + protected function commonPart(string $str1, string $str2, bool $cs = true): string { + for ($i = 0; $i < strlen($str1) && $i < strlen($str2); $i++) { + $chr1 = $str1[$i]; + $chr2 = $str2[$i]; + + if (!$cs) { + $chr1 = strtolower($chr1); + $chr2 = strtolower($chr2); + } + + if ($chr1 !== $chr2) { + break; + } + } + + return substr($str1, 0, $i); + } + + + /** + * @param string $line + * @param array $params + * + * @return string + */ + protected function feedStringWithParams(string $line, array $params): string { + $ak = array_keys($params); + foreach ($ak as $k) { + $line = str_replace('{' . $k . '}', (string)$params[$k], $line); + } + + return $line; + } + + + /** + * @param int $words + * + * @return string + */ + public function generateRandomSentence(int $words = 5): string { + $sentence = []; + for ($i = 0; $i < $words; $i++) { + $sentence[] = $this->generateRandomWord(rand(2, 12)); + } + + return implode(' ', $sentence); + } + + + /** + * @param int $length + * + * @return string + */ + public function generateRandomWord(int $length = 8): string { + $c = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'v']; + $v = ['a', 'e', 'i', 'o', 'u', 'y']; + + $word = []; + for ($i = 0; $i <= ($length / 2); $i++) { + $word[] = $c[array_rand($c)]; + $word[] = $v[array_rand($v)]; + } + + return implode('', $word); + } + + + /** + * @param int $bytes + * + * @return string + */ + public function humanReadable(int $bytes): string { + if ($bytes == 0) { + return '0.00 B'; + } + + $s = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']; + $e = floor(log($bytes, 1024)); + + return round($bytes / pow(1024, $e), 2) . ' ' . $s[$e]; + } + + + /** + * @param int $first + * @param int $second + * @param bool $short + * + * @return string + * @throws Exception + */ + public function getDateDiff( + int $first, + int $second = 0, + bool $short = false, + array $words = [] + ): string { + if ($second === 0) { + $first = time() - $first; + $second = time(); + } + + $f = new DateTime('@' . $first); + $s = new DateTime('@' . $second); + $duration = $second - $first; + if ($short) { + $minutes = $this->get('minutes', $words, 'M'); + $hours = $this->get('hours', $words, 'H'); + $days = $this->get('days', $words, 'D'); + + if ($duration < 60) { + return $f->diff($s)->format('<1' . $minutes); + } + if ($duration < 3600) { + return $f->diff($s)->format('%i' . $minutes); + } + if ($duration < 86400) { + return $f->diff($s)->format('%h' . $hours . ', %i' . $minutes); + } + + return $f->diff($s)->format('%a' . $days . ', %h' . $hours . ', %i' . $minutes); + } + + $seconds = $this->get('seconds', $words, 'seconds'); + $minutes = $this->get('minutes', $words, 'minutes'); + $hours = $this->get('hours', $words, 'hours'); + $days = $this->get('days', $words, 'days'); + if ($duration < 60) { + return $f->diff($s)->format('%s ' . $seconds); + } + + if ($duration < 3600) { + return $f->diff($s)->format('%i ' . $minutes . ' and %s ' . $seconds); + } + + if ($duration < 86400) { + return $f->diff($s)->format('%h ' . $hours . ', %i ' . $minutes . ' and %s ' . $seconds); + } + + return $f->diff($s)->format( + '%a ' . $days . + ', %h ' . $hours . + ', %i ' . $minutes . + ' and %s ' . $seconds + ); + } +}