Download the PHP package tklein/php-combine-conditions without Composer

On this page you can find all versions of the php package tklein/php-combine-conditions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-combine-conditions

PHP Combine Conditions

Codacy Badge Scrutinizer Code Quality Code Climate Latest Stable Version PHP from Packagist

Generic representation of conditional structure/tree library for PHP.

Installation

Composer (recommended)

This package is available through Composer/Packagist:

Getting Started

The combine conditions library for PHP is a tool which helps you to build dynamically structured (as tree or graph) conditions.
These conditions are able to be combined and customized operators can be provided.
This library can be used in many context, to execute advanced combination of conditions, to generate some complex SQL conditions, or to be exported to multiple formats as JSON, XML, FULLTEXT...
An other case to use this library is to execute and process frontend conditional tree (Eg: a user build his conditional tree and would like to process the result).

The library has been written in order to allows you to implement it to the right way you want. So, if you implement the interfaces from the public API, you can build your own combine conditions structure and continue to execute it via the public API services.

The library is written to follow the PSR12 coding standards.

Main Library Entrance

For a simply use, you'll only need to use the following class: \LogicTree\LogicTreeFacade.
This class allows you to use the mainly features of the library, as to build a combined conditions, to execute some, and exports them.

OperatorPool

What's an OperatorPool? It's a class which regroup the whole operator instances used in the library.
You can register or retrieve OperatorInterface from this class. The goal is to use them in your combination of conditions.
The operators are divided in two large groups:

Comparator Operator

The comparator operator is used to determine the result of a boolean expression.
Eg:
Does 'A' and 'B' are the same thing? I can test with an equality operator: 'A' == 'B').

The default comparator operators are available in: src/Operator/Comparator.
It's used in the ConditionInterface definition, known as the Condition object.

Logical Operator

The logical operator is used to commute many boolean expression (at least two).
Eg:
'A' != 'B' result should be the same as 'C' != 'D'.
I can check with the following expression 'A' != 'B' AND 'C' != 'D'.

The default logical operators are available in: src/Operator/Logical.
It's used in the CombineInterface definition, known as the Combine object.

Override/Add new Operators

The library allows you to override the default operators and/or to provide new ones:

Eg: In the following example, we override the default comparators with ours and add a new one.

Now we are able to use these operators in our code and are available everywhere in the library.

Condition and Combine

These class always implement the NodeInterface. It represent the base model of the library.
Because of the composition pattern, you may want to know if the current object is the root or a node, you should use the following methods:

Condition

ConditionInterface: it represents an expression with a comparator operator.
The interface is: \LogicTree\Model\ConditionInterface.
The concrete default class is: \LogicTree\Model\Condition.
It requires a mixed value to compared by an operator to a value from the data source.

The operator is a string which is the code of the wanted operator. The first value is a string which is the identifier of the value from the DataSource object.
The value to compare must be a mixed value.

Combine

Combine: it represents an expression with a logical operator.
The interface is: \LogicTree\Model\CombineInterface. The concrete default class is: \LogicTree\Model\Combine.
It requires at least two conditions and/or combines to commute with a logical operator.

The operator is a string which is the code of the wanted operator.
The conditions/combine must be an instance of ConditionInterface.

You can add a NodeInterface to the CombineInterface with the following methods:

If you want to invert the result of the combination of conditions, you can specify to the CombineInterface object that the result should actually be inverted:

Execute the Combine Conditions

In order to execute the combined conditions, you must use the \LogicTree\Service\ConditionManager class.
This service allows to perform many actions on your NodeInterface object.
Actually only the execute method is available from the public API.
Anyway, the execute method allows you to determine the final result of your combination of conditions.

Export the Combine Conditions to Format

No documentation available yet!

Examples

Examples of code usage cases are available in this file.

Running the tests

The tests are placed in the tests directory, at the root of the library.

No tests available yet!

Contributing

Any help is welcome, feel free to raise issues or to open pull requests. Further details in the CONTRIBUTING.md.

TODO List

Implement the following comparator operators:

  - array("from" => $fromValue, "to" => $toValue)
  - array("like" => $likeValue)
  - array("moreq" => $moreOrEqualValue)
  - array("finset" => $valueInSet)
  - array("seq" => $stringValue)
  - array("sneq" => $stringValue)

ToString methods, in order to render the combine conditions in full text / different formats.
Have to: AdapterPool (toFormat) - ConverterPool (getSymbol, getExpression, getFullExpression).
Possibility to add custom type node and process them in the services.
Study Namespace and Lib Name: trends

Todo Builders (setter... getter... then reset)
-> possibility of immutable implementation (do not break it!)

Add tests and examples: from scratch, with and without new operators, and execution (with expected results).

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details.


All versions of php-combine-conditions with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tklein/php-combine-conditions contains the following files

Loading the files please wait ....