Skip to content

Commit

Permalink
Migrate all features from the QArray
Browse files Browse the repository at this point in the history
  • Loading branch information
nahid committed Aug 22, 2020
1 parent 8b38cea commit fa14e03
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 1,910 deletions.
14 changes: 9 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,29 @@
"keywords": ["json", "jsonq", "query"],
"homepage": "https://github.com/nahid/jsonq",
"type": "library",
"license": "CC0-1.0",
"license": "MIT",
"authors": [
{
"name": "Nahid Bin Azhar",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.5.0"
"php": ">=5.6",
"ext-json": "*",
"nahid/qarray": "^2.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8 || ^5.0",
"symfony/var-dumper": "^3.4",
"graham-campbell/testbench": "^3.1"
"symfony/var-dumper": "^3.4"
},
"autoload": {
"psr-4": {
"Nahid\\JsonQ\\": "src/"
}
},
"files": [
"helpers/jsonq.php"
]
},
"autoload-dev": {
"psr-4": {
Expand Down
7 changes: 0 additions & 7 deletions config/jsonq.php

This file was deleted.

13 changes: 9 additions & 4 deletions examples/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,20 @@
//});
//

$jq = new Jsonq('data.json');
//$jq = new Jsonq('data.json');

try {
$result = $jq->from('users')
$data = file_get_contents('data.json');
// This will remove unwanted characters.
// Check http://www.php.net/chr for details

$result = jsonq($data)
->from('users')
->where('visits.year', '=', 2010)
->sum('visits.year');
->get();
dump($result);
} catch (\Nahid\JsonQ\Exceptions\ConditionNotAllowedException $e) {

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

}
}
11 changes: 11 additions & 0 deletions helpers/jsonq.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

if (!function_exists('jsonq')) {
function jsonq($jsonData)
{
if (!is_string($jsonData)) throw new \Nahid\QArray\Exceptions\InvalidJsonException();

$json = new Nahid\JsonQ\Jsonq();
return $json->collect($json->parseData($jsonData));
}
}
280 changes: 0 additions & 280 deletions src/Condition.php

This file was deleted.

11 changes: 0 additions & 11 deletions src/Exceptions/ConditionNotAllowedException.php

This file was deleted.

11 changes: 0 additions & 11 deletions src/Exceptions/FileNotFoundException.php

This file was deleted.

11 changes: 0 additions & 11 deletions src/Exceptions/InvalidJsonException.php

This file was deleted.

Loading

0 comments on commit fa14e03

Please sign in to comment.