Skip to content

Commit fa14e03

Browse files
committed
Migrate all features from the QArray
1 parent 8b38cea commit fa14e03

18 files changed

+62
-1910
lines changed

composer.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,29 @@
44
"keywords": ["json", "jsonq", "query"],
55
"homepage": "https://github.com/nahid/jsonq",
66
"type": "library",
7-
"license": "CC0-1.0",
7+
"license": "MIT",
88
"authors": [
99
{
1010
"name": "Nahid Bin Azhar",
1111
"email": "[email protected]"
1212
}
1313
],
1414
"require": {
15-
"php": ">=5.5.0"
15+
"php": ">=5.6",
16+
"ext-json": "*",
17+
"nahid/qarray": "^2.0"
1618
},
1719
"require-dev": {
1820
"phpunit/phpunit": "^4.8 || ^5.0",
19-
"symfony/var-dumper": "^3.4",
20-
"graham-campbell/testbench": "^3.1"
21+
"symfony/var-dumper": "^3.4"
2122
},
2223
"autoload": {
2324
"psr-4": {
2425
"Nahid\\JsonQ\\": "src/"
25-
}
26+
},
27+
"files": [
28+
"helpers/jsonq.php"
29+
]
2630
},
2731
"autoload-dev": {
2832
"psr-4": {

config/jsonq.php

Lines changed: 0 additions & 7 deletions
This file was deleted.

examples/index.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,20 @@
1515
//});
1616
//
1717

18-
$jq = new Jsonq('data.json');
18+
//$jq = new Jsonq('data.json');
1919

2020
try {
21-
$result = $jq->from('users')
21+
$data = file_get_contents('data.json');
22+
// This will remove unwanted characters.
23+
// Check http://www.php.net/chr for details
24+
25+
$result = jsonq($data)
26+
->from('users')
2227
->where('visits.year', '=', 2010)
23-
->sum('visits.year');
28+
->get();
2429
dump($result);
2530
} catch (\Nahid\JsonQ\Exceptions\ConditionNotAllowedException $e) {
2631

2732
} catch (\Nahid\JsonQ\Exceptions\NullValueException $e) {
2833

29-
}
34+
}

helpers/jsonq.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
if (!function_exists('jsonq')) {
4+
function jsonq($jsonData)
5+
{
6+
if (!is_string($jsonData)) throw new \Nahid\QArray\Exceptions\InvalidJsonException();
7+
8+
$json = new Nahid\JsonQ\Jsonq();
9+
return $json->collect($json->parseData($jsonData));
10+
}
11+
}

src/Condition.php

Lines changed: 0 additions & 280 deletions
This file was deleted.

src/Exceptions/ConditionNotAllowedException.php

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/Exceptions/FileNotFoundException.php

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/Exceptions/InvalidJsonException.php

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)