Skip to content
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

Merged
merged 12 commits into from
Aug 14, 2023

Conversation

rakoitde
Copy link
Contributor

@rakoitde rakoitde commented Aug 6, 2023

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:

  • I have read the code of conduct and accept it.
  • I have read the contributing guidelines and accept them.
  • I accept that my contribution will be licensed under the AGPLv3.

README.md Outdated
~~~

You can use more than one condition and add an operator to them.
Allowed oprerators are 'AND' and 'OR'.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

* 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/>
Copy link
Member

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 😉


public $operator;

public function where($const, $property):self
Copy link
Member

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 {
Copy link
Member

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

Copy link
Member

@bheisig bheisig left a 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.

@bheisig
Copy link
Member

bheisig commented Aug 14, 2023

Please check failed checks on PHP 8.0 and 8.1.

Kornberger, Ralf added 4 commits August 14, 2023 09:52
with type declarations the characters in this lines exceeds 120. so i have to remove type declarations.
@bheisig bheisig merged commit 47d5979 into i-doit:main Aug 14, 2023
2 of 4 checks passed
@rakoitde rakoitde deleted the condition branch August 14, 2023 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants