Skip to content

Commit 302980f

Browse files
committed
Initial commit
0 parents  commit 302980f

File tree

12 files changed

+2548
-0
lines changed

12 files changed

+2548
-0
lines changed

.codeclimate.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
engines:
2+
phpmd:
3+
enabled: true
4+
checks:
5+
Design/TooManyPublicMethods:
6+
enabled: true
7+
Naming/ShortVariable:
8+
enabled: true
9+
CleanCode/StaticAccess:
10+
enabled: true
11+
Controversial/CamelCaseMethodName:
12+
enabled: true
13+
fixme:
14+
enabled: true
15+
duplication:
16+
enabled: true
17+
config:
18+
languages:
19+
- php:
20+
ratings:
21+
paths:
22+
- src/**

.gitignore

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
composer.phar
2+
.DS_Store
3+
*~
4+
/devel/
5+
/coverage.clover
6+
.idea/
7+
8+
### Composer template
9+
/vendor/
10+
11+
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
12+
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
13+
# composer.lock
14+
### Windows template
15+
# Windows thumbnail cache files
16+
Thumbs.db
17+
ehthumbs.db
18+
ehthumbs_vista.db
19+
20+
# Dump file
21+
*.stackdump
22+
23+
# Folder config file
24+
[Dd]esktop.ini
25+
26+
# Recycle Bin used on file shares
27+
$RECYCLE.BIN/
28+
29+
# Windows Installer files
30+
*.cab
31+
*.msi
32+
*.msm
33+
*.msp
34+
35+
# Windows shortcuts
36+
*.lnk
37+
### JetBrains template
38+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
39+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
40+
41+
# User-specific stuff:
42+
.idea/**/workspace.xml
43+
.idea/**/tasks.xml
44+
.idea/dictionaries
45+
46+
# Sensitive or high-churn files:
47+
.idea/**/dataSources/
48+
.idea/**/dataSources.ids
49+
.idea/**/dataSources.xml
50+
.idea/**/dataSources.local.xml
51+
.idea/**/sqlDataSources.xml
52+
.idea/**/dynamic.xml
53+
.idea/**/uiDesigner.xml
54+
55+
# Gradle:
56+
.idea/**/gradle.xml
57+
.idea/**/libraries
58+
59+
# CMake
60+
cmake-build-debug/
61+
62+
# Mongo Explorer plugin:
63+
.idea/**/mongoSettings.xml
64+
65+
## File-based project format:
66+
*.iws
67+
68+
## Plugin-specific files:
69+
70+
# IntelliJ
71+
out/
72+
73+
# mpeltonen/sbt-idea plugin
74+
.idea_modules/
75+
76+
# JIRA plugin
77+
atlassian-ide-plugin.xml
78+
79+
# Cursive Clojure plugin
80+
.idea/replstate.xml
81+
82+
# Crashlytics plugin (for Android Studio and IntelliJ)
83+
com_crashlytics_export_strings.xml
84+
crashlytics.properties
85+
crashlytics-build.properties
86+
fabric.properties

.scrutinizer.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
build:
2+
tests:
3+
override:
4+
-
5+
command: './vendor/bin/phpunit --coverage-clover=coverage.clover'
6+
coverage:
7+
file: 'coverage.clover'
8+
format: 'clover'
9+
checks:
10+
php:
11+
code_rating: true
12+
duplication: true
13+

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
sudo: false
2+
3+
language: php
4+
5+
php:
6+
- 7.1
7+
8+
before_script:
9+
- curl -sS http://getcomposer.org/installer | php
10+
- php composer.phar install --prefer-source --no-interaction
11+
12+
script:
13+
- ./vendor/bin/phpunit

README.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# pecee/boolean-query-parser
2+
3+
Convert a boolean search query into a query that is compatible with a fulltext search.
4+
5+
### Notes
6+
7+
This library is a maintained fork of the original project "BooleanSearchParser" created by DuncanOglethat, [available here](https://github.com/DuncanOgle/BooleanSearchParser).
8+
9+
The goal of this project is to iron out bugs, optimise the code, add new features and make it compatible with future versions of PHP.
10+
11+
## Requirements
12+
13+
- PHP 7.1 or higher
14+
15+
### Installation
16+
17+
```
18+
composer require pecee/boolean-query-parser
19+
```
20+
21+
### Parsing a query
22+
23+
```php
24+
$parser = new \Pecee\BooleanQueryParser\BooleanQueryParser();
25+
26+
$formattedQuery = $parser->parse('ict OR (technology AND bob)');
27+
```
28+
29+
**Output**
30+
31+
```
32+
ict (+technology +bob)
33+
```
34+
35+
### Order
36+
37+
Order and brackets are important, more often than not OR logic takes priority
38+
39+
`sales OR finance AND manager` will become `sales finance +manager` and not `sales +finance +manager`
40+
41+
## Examples
42+
43+
|Input|Output|
44+
|-----|------|
45+
|`ict` | `+ict`|
46+
|`ict it` | `+ict +it`|
47+
|`ict OR it` | `ict it`|
48+
|`NOT ict` | `-ict`|
49+
|`it NOT ict` | `+it -ict`|
50+
|`web AND (ict OR it)` | `+web +(ict it)`|
51+
|`ict OR (it AND web)` | `ict (+it +web)`|
52+
|`ict NOT (ict AND it AND web)` | `+ict -(+ict +it +web)`|
53+
|`php OR (NOT web NOT embedded ict OR it)` | `php (-web -embedded ict it)`|
54+
|`(web OR embedded) (ict OR it)` | `+(web embedded) +(ict it)`|
55+
|`develop AND (web OR (ict AND php))` | `+develop +(web (+ict +php))`|
56+
|`"ict` | `null `|
57+
|`"ict OR it"` | `+"ict OR it"`|
58+
59+
## Advanced examples
60+
|Input|Output|
61+
|-----|------|
62+
`"business development" or "it sales" and (danish or dutch or italian or denmark or holland or netherlands or italy)` | `"business development" "it sales" +(danish dutch italian denmark holland netherlands italy)`
63+
`(procurement or buying or purchasing) and (marine or sea) and (engineering or engineer)` | `+(procurement buying purchasing) +(marine sea) +(engineering engineer)`
64+
65+
## Licence
66+
67+
Licensed under the MIT licence.
68+
69+
### The MIT License (MIT)
70+
71+
Copyright (c) 2018 Simon Sessingø / pecee-boolean-query-parser
72+
73+
Permission is hereby granted, free of charge, to any person obtaining a copy
74+
of this software and associated documentation files (the "Software"), to deal
75+
in the Software without restriction, including without limitation the rights
76+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
77+
copies of the Software, and to permit persons to whom the Software is
78+
furnished to do so, subject to the following conditions:
79+
80+
The above copyright notice and this permission notice shall be included in all
81+
copies or substantial portions of the Software.
82+
83+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
84+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
85+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
86+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
87+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
88+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
89+
SOFTWARE.

composer.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "pecee/boolean-query-parser",
3+
"description": "Convert a boolean search query into a query that is compatible with a fulltext search.",
4+
"homepage": "https://github.com/skipperbent/boolean-query-parser",
5+
"keywords": [
6+
"boolean search parser",
7+
"boolean query parser",
8+
"boolean query formatter",
9+
"boolean query parser",
10+
"mysql fulltext formatter",
11+
"query formatter",
12+
"query parser",
13+
"fulltext query format",
14+
"parser",
15+
"mysql",
16+
"database"
17+
],
18+
"license": "MIT",
19+
"minimum-stability": "stable",
20+
"authors": [
21+
{
22+
"name": "Simon Sessingø",
23+
"email": "simon.sessingoe@gmail.com",
24+
"role": "Developer"
25+
}
26+
],
27+
"require": {
28+
"php": ">=7.1"
29+
},
30+
"require-dev": {
31+
"phpunit/phpunit": "^6.0",
32+
"mockery/mockery": "^1"
33+
},
34+
"autoload": {
35+
"psr-4": {
36+
"Pecee\\BooleanQueryParser\\": "src/Pecee/BooleanQueryParser/"
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)