Jql Builder
Simple JQL builder for Jira search
Installation
composer require devmoath/jql-builder
Usage
Generate query with one condition:
\DevMoath\JqlBuilder\Jql::query()
->whereProject('MY PROJECT')
->getQuery(); // "project = 'MY PROJECT'"
Generate query with many conditions:
\DevMoath\JqlBuilder\Jql::query()
->whereProject('MY PROJECT')
->whereIssueType('support')
->whereStatus(['wip', 'created'], Jql::IN)
->getQuery(); // "project = 'MY PROJECT' and issuetype = 'support' and status in ('wip', 'created')"
generate query with custom filed conditions:
\DevMoath\JqlBuilder\Jql::query()
->where('customfild_111', \DevMoath\JqlBuilder\Jql::EQUAL, 'value')
->where('customfild_222', \DevMoath\JqlBuilder\Jql::EQUAL, 'value')
->getQuery(); // "customfild_111 = 'value' and customfild_222 = 'value'"
generate query conditions based on your condition:
\DevMoath\JqlBuilder\Jql::query()
->when('MY PROJECT', fn (\DevMoath\JqlBuilder\Jql $builder, $value) => $builder->whereProject($value))
->when('', fn (\DevMoath\JqlBuilder\Jql $builder, $value) => $builder->whereIssueType($value))
->getQuery(); // "project = 'MY PROJECT'"
Also you can add macro functions as well:
$builder = new \DevMoath\JqlBuilder\Jql;
$builder::macro('whereCustom', function ($value) {
/** @var Jql $this */
return $this->where('custom', \DevMoath\JqlBuilder\Jql::EQUAL, $value);
});
$builder->whereCustom('1')->getQuery(); // "custom = '1'"
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.