Completed
Push — master ( f50a49...f3277c )
by Sherif
03:02
created
src/Modules/V1/Core/AbstractRepositories/AbstractRepositoryContainer.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -4,39 +4,39 @@
 block discarded – undo
4 4
 
5 5
 abstract class AbstractRepositoryContainer implements RepositoryContainerInterface
6 6
 {
7
-    /**
8
-     * Construct the repository class name based on
9
-     * the method name called, search in the 
10
-     * given namespaces for the class and 
11
-     * return an instance.
12
-     * 
13
-     * @param  string $name the called method name
14
-     * @param  array  $arguments the method arguments
15
-     * @return object
16
-     */
17
-    public function __call($name, $arguments)
18
-    {
19
-        foreach ($this->getRepoNameSpace() as $repoNameSpace) 
20
-        {
21
-            $class = rtrim($repoNameSpace, '\\') . '\\' . ucfirst(str_singular($name)) . 'Repository';
22
-            if (class_exists($class)) 
23
-            {
24
-                \App::singleton($class, function ($app) use ($class) {
7
+	/**
8
+	 * Construct the repository class name based on
9
+	 * the method name called, search in the 
10
+	 * given namespaces for the class and 
11
+	 * return an instance.
12
+	 * 
13
+	 * @param  string $name the called method name
14
+	 * @param  array  $arguments the method arguments
15
+	 * @return object
16
+	 */
17
+	public function __call($name, $arguments)
18
+	{
19
+		foreach ($this->getRepoNameSpace() as $repoNameSpace) 
20
+		{
21
+			$class = rtrim($repoNameSpace, '\\') . '\\' . ucfirst(str_singular($name)) . 'Repository';
22
+			if (class_exists($class)) 
23
+			{
24
+				\App::singleton($class, function ($app) use ($class) {
25 25
 
26
-                    return new \App\Modules\V1\Core\Decorators\CachingDecorator(new $class, $app['cache.store']);
27
-                });
26
+					return new \App\Modules\V1\Core\Decorators\CachingDecorator(new $class, $app['cache.store']);
27
+				});
28 28
 
29
-                return \App::make($class);
30
-            }
31
-        }
32
-    }
29
+				return \App::make($class);
30
+			}
31
+		}
32
+	}
33 33
 
34
-     /**
35
-     * Abstract methods that return the necessary 
36
-     * information (repositories namespaces)
37
-     * needed to preform the previous actions.
38
-     * 
39
-     * @return array
40
-     */
41
-    abstract protected function getRepoNameSpace();
34
+	 /**
35
+	  * Abstract methods that return the necessary 
36
+	  * information (repositories namespaces)
37
+	  * needed to preform the previous actions.
38
+	  * 
39
+	  * @return array
40
+	  */
41
+	abstract protected function getRepoNameSpace();
42 42
 }
43 43
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,10 +18,10 @@
 block discarded – undo
18 18
     {
19 19
         foreach ($this->getRepoNameSpace() as $repoNameSpace) 
20 20
         {
21
-            $class = rtrim($repoNameSpace, '\\') . '\\' . ucfirst(str_singular($name)) . 'Repository';
21
+            $class = rtrim($repoNameSpace, '\\').'\\'.ucfirst(str_singular($name)).'Repository';
22 22
             if (class_exists($class)) 
23 23
             {
24
-                \App::singleton($class, function ($app) use ($class) {
24
+                \App::singleton($class, function($app) use ($class) {
25 25
 
26 26
                     return new \App\Modules\V1\Core\Decorators\CachingDecorator(new $class, $app['cache.store']);
27 27
                 });
Please login to merge, or discard this patch.
src/Modules/V1/Core/Database/Migrations/2016_01_24_123630_settings.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@
 block discarded – undo
13 13
 	public function up()
14 14
 	{
15 15
 		Schema::create('settings', function (Blueprint $table) {
16
-            $table->increments('id');
17
-            $table->string('name',100);
18
-            $table->string('key',100)->unique();
19
-            $table->text('value')->nullable();
20
-            $table->softDeletes();
21
-            $table->timestamps();
22
-        });
16
+			$table->increments('id');
17
+			$table->string('name',100);
18
+			$table->string('key',100)->unique();
19
+			$table->text('value')->nullable();
20
+			$table->softDeletes();
21
+			$table->timestamps();
22
+		});
23 23
 	}
24 24
 
25 25
 	/**
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@
 block discarded – undo
12 12
 	 */
13 13
 	public function up()
14 14
 	{
15
-		Schema::create('settings', function (Blueprint $table) {
15
+		Schema::create('settings', function(Blueprint $table) {
16 16
             $table->increments('id');
17
-            $table->string('name',100);
18
-            $table->string('key',100)->unique();
17
+            $table->string('name', 100);
18
+            $table->string('key', 100)->unique();
19 19
             $table->text('value')->nullable();
20 20
             $table->softDeletes();
21 21
             $table->timestamps();
Please login to merge, or discard this patch.
src/Modules/V1/Core/Http/Controllers/SettingsController.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -8,20 +8,20 @@
 block discarded – undo
8 8
 
9 9
 class SettingsController extends BaseApiController
10 10
 {
11
-    /**
12
-     * The name of the model that is used by the base api controller 
13
-     * to preform actions like (add, edit ... etc).
14
-     * @var string
15
-     */
16
-    protected $model               = 'settings';
11
+	/**
12
+	 * The name of the model that is used by the base api controller 
13
+	 * to preform actions like (add, edit ... etc).
14
+	 * @var string
15
+	 */
16
+	protected $model               = 'settings';
17 17
 
18
-    /**
19
-     * The validations rules used by the base api controller
20
-     * to check before add.
21
-     * @var array
22
-     */
23
-    protected $validationRules  = [
24
-    'name'  => 'required|string|max:100',
25
-    'value' => 'required|string'
26
-    ];
18
+	/**
19
+	 * The validations rules used by the base api controller
20
+	 * to check before add.
21
+	 * @var array
22
+	 */
23
+	protected $validationRules  = [
24
+	'name'  => 'required|string|max:100',
25
+	'value' => 'required|string'
26
+	];
27 27
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@
 block discarded – undo
13 13
      * to preform actions like (add, edit ... etc).
14 14
      * @var string
15 15
      */
16
-    protected $model               = 'settings';
16
+    protected $model = 'settings';
17 17
 
18 18
     /**
19 19
      * The validations rules used by the base api controller
20 20
      * to check before add.
21 21
      * @var array
22 22
      */
23
-    protected $validationRules  = [
23
+    protected $validationRules = [
24 24
     'name'  => 'required|string|max:100',
25 25
     'value' => 'required|string'
26 26
     ];
Please login to merge, or discard this patch.
src/Modules/V1/Core/Decorators/CachingDecorator.php 3 patches
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -2,92 +2,92 @@
 block discarded – undo
2 2
 
3 3
 class CachingDecorator
4 4
 {
5
-    /**
6
-     * The repo implementation.
7
-     * 
8
-     * @var string
9
-     */
10
-    protected $repo;
5
+	/**
6
+	 * The repo implementation.
7
+	 * 
8
+	 * @var string
9
+	 */
10
+	protected $repo;
11 11
 
12
-    /**
13
-     * The cache implementation.
14
-     * 
15
-     * @var object
16
-     */
17
-    protected $cache;
12
+	/**
13
+	 * The cache implementation.
14
+	 * 
15
+	 * @var object
16
+	 */
17
+	protected $cache;
18 18
 
19
-    /**
20
-     * The model implementation.
21
-     * 
22
-     * @var string
23
-     */
24
-    public $model;
19
+	/**
20
+	 * The model implementation.
21
+	 * 
22
+	 * @var string
23
+	 */
24
+	public $model;
25 25
 
26
-    /**
27
-     * The cacheConfig implementation.
28
-     * 
29
-     * @var array
30
-     */
31
-    public $cacheConfig;
26
+	/**
27
+	 * The cacheConfig implementation.
28
+	 * 
29
+	 * @var array
30
+	 */
31
+	public $cacheConfig;
32 32
     
33
-    /**
34
-     * Create new CachingDecorator instance.
35
-     */
36
-    public function __construct($repo, $cache)
37
-    {   
38
-        $this->repo  = $repo;
39
-        $this->cache = $cache;
40
-        $this->model = get_class($this->repo->model);
41
-    }
33
+	/**
34
+	 * Create new CachingDecorator instance.
35
+	 */
36
+	public function __construct($repo, $cache)
37
+	{   
38
+		$this->repo  = $repo;
39
+		$this->cache = $cache;
40
+		$this->model = get_class($this->repo->model);
41
+	}
42 42
 
43
-    /**
44
-     * Handle the cache mechanism for the called method
45
-     * based the configurations.
46
-     * 
47
-     * @param  string $name the called method name
48
-     * @param  array  $arguments the method arguments
49
-     * @return object
50
-     */
51
-    public function __call($name, $arguments)
52
-    {
53
-        $this->setCacheConfig($name);
43
+	/**
44
+	 * Handle the cache mechanism for the called method
45
+	 * based the configurations.
46
+	 * 
47
+	 * @param  string $name the called method name
48
+	 * @param  array  $arguments the method arguments
49
+	 * @return object
50
+	 */
51
+	public function __call($name, $arguments)
52
+	{
53
+		$this->setCacheConfig($name);
54 54
 
55
-        if ($this->cacheConfig && $this->cacheConfig == 'cache') 
56
-        {
57
-            $page     = \Request::get('page') ?? '1';
58
-            $cacheKey = $name . $page . serialize($arguments);
59
-            return $this->cache->tags([$this->model])->rememberForever($cacheKey, function() use ($arguments, $name) {
60
-                return call_user_func_array([$this->repo, $name], $arguments);
61
-            });
62
-        }
63
-        else if ($this->cacheConfig)
64
-        {
65
-            $this->cache->tags($this->cacheConfig)->flush();
66
-            return call_user_func_array([$this->repo, $name], $arguments);
67
-        }
55
+		if ($this->cacheConfig && $this->cacheConfig == 'cache') 
56
+		{
57
+			$page     = \Request::get('page') ?? '1';
58
+			$cacheKey = $name . $page . serialize($arguments);
59
+			return $this->cache->tags([$this->model])->rememberForever($cacheKey, function() use ($arguments, $name) {
60
+				return call_user_func_array([$this->repo, $name], $arguments);
61
+			});
62
+		}
63
+		else if ($this->cacheConfig)
64
+		{
65
+			$this->cache->tags($this->cacheConfig)->flush();
66
+			return call_user_func_array([$this->repo, $name], $arguments);
67
+		}
68 68
 
69
-        return call_user_func_array([$this->repo, $name], $arguments);
70
-    }
69
+		return call_user_func_array([$this->repo, $name], $arguments);
70
+	}
71 71
 
72
-    /**
73
-     * Set cache config based on the called method.
74
-     * 
75
-     * @param  string $name
76
-     * @return void
77
-     */
78
-    private function setCacheConfig($name)
79
-    {
80
-        $config            = \CoreConfig::getConfig();
81
-        $cacheConfig       = array_key_exists($this->model, $config['cacheConfig']) ? $config['cacheConfig'][$this->model] : false;
82
-        $this->cacheConfig = false;
72
+	/**
73
+	 * Set cache config based on the called method.
74
+	 * 
75
+	 * @param  string $name
76
+	 * @return void
77
+	 */
78
+	private function setCacheConfig($name)
79
+	{
80
+		$config            = \CoreConfig::getConfig();
81
+		$cacheConfig       = array_key_exists($this->model, $config['cacheConfig']) ? $config['cacheConfig'][$this->model] : false;
82
+		$this->cacheConfig = false;
83 83
 
84
-        if (in_array($cacheConfig['cache'], $name))
85
-        {
86
-            $this->cacheConfig = 'cache';
87
-        }
88
-        else if (in_array($cacheConfig['clear'], $name))
89
-        {
90
-            $this->cacheConfig = $cacheConfig['clear'][$name];
91
-        }
92
-    }
84
+		if (in_array($cacheConfig['cache'], $name))
85
+		{
86
+			$this->cacheConfig = 'cache';
87
+		}
88
+		else if (in_array($cacheConfig['clear'], $name))
89
+		{
90
+			$this->cacheConfig = $cacheConfig['clear'][$name];
91
+		}
92
+	}
93 93
 }
94 94
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
         if ($this->cacheConfig && $this->cacheConfig == 'cache') 
56 56
         {
57 57
             $page     = \Request::get('page') ?? '1';
58
-            $cacheKey = $name . $page . serialize($arguments);
58
+            $cacheKey = $name.$page.serialize($arguments);
59 59
             return $this->cache->tags([$this->model])->rememberForever($cacheKey, function() use ($arguments, $name) {
60 60
                 return call_user_func_array([$this->repo, $name], $arguments);
61 61
             });
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -59,8 +59,7 @@  discard block
 block discarded – undo
59 59
             return $this->cache->tags([$this->model])->rememberForever($cacheKey, function() use ($arguments, $name) {
60 60
                 return call_user_func_array([$this->repo, $name], $arguments);
61 61
             });
62
-        }
63
-        else if ($this->cacheConfig)
62
+        } else if ($this->cacheConfig)
64 63
         {
65 64
             $this->cache->tags($this->cacheConfig)->flush();
66 65
             return call_user_func_array([$this->repo, $name], $arguments);
@@ -84,8 +83,7 @@  discard block
 block discarded – undo
84 83
         if (in_array($cacheConfig['cache'], $name))
85 84
         {
86 85
             $this->cacheConfig = 'cache';
87
-        }
88
-        else if (in_array($cacheConfig['clear'], $name))
86
+        } else if (in_array($cacheConfig['clear'], $name))
89 87
         {
90 88
             $this->cacheConfig = $cacheConfig['clear'][$name];
91 89
         }
Please login to merge, or discard this patch.