Skip to content

Commit 1e145e6

Browse files
committed
refactor: ♻️ PSR 4 Standard
1 parent 94c8e0e commit 1e145e6

19 files changed

+133
-63
lines changed

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727
"require-dev": {
2828
"phpunit/phpunit": "^9.0",
2929
"phpunit/php-code-coverage": "^8.0",
30-
"sami/sami": "^4.1"
30+
"code-lts/doctum": "^5.3"
31+
},
32+
"scripts": {
33+
"generate:docs": "vendor/bin/doctum.php update ./config.php",
34+
"test": "vendor/bin/phpunit"
3135
},
3236
"require": {
3337
"php" : ">=5.5.0"

config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?php
22

3-
return new Sami\Sami('/Users/uttamukkoji/Documents/php/contentstack-php/src');
3+
return new Doctum\Doctum('./src');
44

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
use Contentstack\Stack\Stack;
1818

19-
require_once __DIR__ . '/lib/models/stack.php';
20-
2119
/**
2220
* Contentstack abstract class to provide access to Stack Object
2321
*
@@ -37,15 +35,15 @@ abstract class Contentstack
3735
* @param string $api_key : Contentstack Stack API KEY.
3836
* @param string $access_token : Contentstack Stack ACCESS TOKEN.
3937
* @param string $environment : Environment Name.
40-
* @param ContentstackRegion $region : Region name of Contentstack.
38+
* @param array $config : Stack Configuration to provide region.
4139
*
4240
* @return Stack
4341
* */
4442
public static function Stack($api_key = '',
4543
$access_token = '',
4644
$environment = '',
47-
$region = ''
45+
$config = array('region'=> '')
4846
) {
49-
return new Stack($api_key, $access_token, $environment, $region);
47+
return new Stack($api_key, $access_token, $environment, $config);
5048
}
5149
}
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,14 @@
1414
* @license https://github.com/contentstack/contentstack-php/blob/master/LICENSE.txt MIT Licence
1515
* @link https://pear.php.net/package/contentstack
1616
* */
17-
namespace Contentstack\Stack\Assets;
17+
namespace Contentstack\Stack;
1818

19-
require_once __DIR__ . "/../../Support/helper.php";
19+
require_once __DIR__ . "/../Support/helper.php";
2020

21-
use Contentstack\Stack\ContentType\Query\Query;
22-
use Contentstack\Stack\ContentType\BaseQuery\BaseQuery;
21+
use Contentstack\Stack\ContentType\Query;
22+
use Contentstack\Stack\BaseQuery;
2323
use Contentstack\Support\Utility;
2424

25-
26-
require_once __DIR__.'/query.php';
27-
require_once __DIR__."/base_query.php";
28-
require_once __DIR__."/../../Support/Utility.php";
29-
30-
3125
/**
3226
* Assets refer to all the media files (images, videos, PDFs,
3327
* audio files, and so on) uploaded in your Contentstack
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
* @link https://pear.php.net/package/contentstack
1515
* */
1616

17-
namespace Contentstack\Stack\ContentType\BaseQuery;
17+
namespace Contentstack\Stack;
1818
use Contentstack\Support\Utility;
1919

20-
require_once __DIR__ . "/../../Support/helper.php";
21-
require_once __DIR__."/../../Support/Utility.php";
20+
require_once __DIR__ . "/../Support/helper.php";
21+
2222
/**
2323
* BaseQuery
2424
* Base Class where all the Queries will be created
@@ -128,7 +128,7 @@ public function only($level = 'BASE', $field_uids = array())
128128
* */
129129
public function includeReference($field_uids = array())
130130
{
131-
if (is_array($field_uids)) {
131+
if ($field_uids && is_array($field_uids)) {
132132
$this->queryObject->_query = call_user_func(
133133
'contentstackReferences',
134134
'include',
@@ -465,7 +465,7 @@ public function skip($skip = 0)
465465
* */
466466
public function tags($tags = array())
467467
{
468-
if (is_array($tags)) {
468+
if ($tags && is_array($tags)) {
469469
$this->queryObject->_query = call_user_func(
470470
'contentstackTags',
471471
'tags',
@@ -508,7 +508,7 @@ public function limit($limit = '')
508508
* */
509509
public function containedIn($field = '', $value = array())
510510
{
511-
if (is_array($value)) {
511+
if ($value && is_array($value)) {
512512
$this->subQuery = call_user_func(
513513
'contentstackContains',
514514
'$in',
@@ -533,7 +533,7 @@ public function containedIn($field = '', $value = array())
533533
* */
534534
public function notContainedIn($field = '', $value = array())
535535
{
536-
if (is_array($value)) {
536+
if ($value && is_array($value)) {
537537
$this->subQuery = call_user_func(
538538
'contentstackContains',
539539
'$nin',
@@ -675,8 +675,8 @@ public function notEqualTo($field = '', $value = '')
675675
* */
676676
public function addQuery($_query = array())
677677
{
678-
if (is_array($_query)) {
679-
$this->subQuery = $_query;
678+
if ($_query && is_array($_query)) {
679+
$this->subQuery = json_encode($_query);
680680
return $this->queryObject;
681681
}
682682
throw contentstackCreateError("Provide valid query");
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,11 @@
1515
* @link https://pear.php.net/package/contentstack
1616
* */
1717

18-
namespace Contentstack\Stack\ContentType;
18+
namespace Contentstack\Stack;
1919

20-
use Contentstack\Stack\ContentType\Entry\Entry;
21-
use Contentstack\Stack\ContentType\Query\Query;
22-
//use Contentstack\Stack\ContentType\Query\Fetch;
20+
use Contentstack\Stack\ContentType\Entry;
21+
use Contentstack\Stack\ContentType\Query;
2322
use Contentstack\Support\Utility;
24-
require_once __DIR__.'/entry.php';
25-
require_once __DIR__.'/query.php';
26-
require_once __DIR__."/../../Support/Utility.php";
2723
/**
2824
* Class ContentType
2925
*
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@
1414
* @link https://pear.php.net/package/contentstack
1515
* */
1616

17-
namespace Contentstack\Stack\ContentType\Entry;
17+
namespace Contentstack\Stack\ContentType;
1818

19-
use Contentstack\Stack\ContentType\BaseQuery\BaseQuery;
19+
use Contentstack\Stack\BaseQuery;
2020
use Contentstack\Support\Utility;
2121

22-
require_once __DIR__."/base_query.php";
23-
require_once __DIR__."/../../Support/Utility.php";
2422
/**
2523
* Entry
2624
*

0 commit comments

Comments
 (0)