-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Condition helper class for more readable code #30
Conversation
README.md
Outdated
~~~ | ||
|
||
You can use more than one condition and add an operator to them. | ||
Allowed oprerators are 'AND' and 'OR'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
src/Condition.php
Outdated
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* @author Benjamin Heisig <https://benjamin.heisig.name/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove me as the author 😉
src/Condition.php
Outdated
|
||
public $operator; | ||
|
||
public function where($const, $property):self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type declarations would be great, e.g. string $const, $string $property
.
|
||
use \Exception; | ||
|
||
class ConditionTest extends BaseTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some test data would be helpful for the tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution. This new feature looks great. I've added some small hints which should be addressed before merging.
Please check failed checks on PHP 8.0 and 8.1. |
with type declarations the characters in this lines exceeds 120. so i have to remove type declarations.
Add Condition helper class for more readable code
Added
File: src/Condition.php
Example:
use Idoit\APIClient\API;
use Idoit\APIClient\CMDBCondition;
use Idoit\APIClient\Condition;
$api = new API([/* … */]);
$condition = new CMDBCondition($api);
$conditions = [
new Condition("C__CATG__ACCOUNTING", "order_no", "=", "ORDER4711"),
new Condition("C__CATG__ACCOUNTING", "order_no", "=", "ORDER4711", Condition::OR),
];
$result = $condition->read($conditions);
File: tests/Idoit/APIClient/ConditionTest.php
Changed
Fiel: README.md
Confirmation
By sending this pull request I accept the following conditions: