Test Setup Failed
Push — develop ( b46587...bd8dda )
by Craig
07:01
created
src/Datastore.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -15,14 +15,14 @@  discard block
 block discarded – undo
15 15
 use ReflectionClass;
16 16
 use ReflectionProperty;
17 17
 
18
-class Datastore{
18
+class Datastore {
19 19
 
20
-	protected $__asset				 = false;
21
-	protected $__asset_properties	 = false;
22
-	protected $__value_equals		 = false;
23
-	protected $__status_equals		 = false;
24
-	protected $__start_date			 = null;
25
-	protected $__end_date			 = null;
20
+	protected $__asset = false;
21
+	protected $__asset_properties = false;
22
+	protected $__value_equals = false;
23
+	protected $__status_equals = false;
24
+	protected $__start_date = null;
25
+	protected $__end_date = null;
26 26
 
27 27
 	/**
28 28
 	 *
@@ -55,17 +55,17 @@  discard block
 block discarded – undo
55 55
 		{
56 56
 			$this->__model = DatastoreModel::findOrFail($id);
57 57
 
58
-			if(!$this->__model){
58
+			if (!$this->__model) {
59 59
 				//could not load <div class="">thr</div>
60 60
 				throw new DatastoreException("Record not found");
61 61
 			}
62 62
 
63 63
 			foreach ($this->__model->toArray() as $k => $v)
64 64
 			{
65
-				if($k === 'options' || $k === 'meta'){
65
+				if ($k === 'options' || $k === 'meta') {
66 66
 					$v = json_decode($v, true);
67 67
 				}
68
-				if(in_array($k, ['created_at','updated_at','date_start','date_end'])){
68
+				if (in_array($k, ['created_at', 'updated_at', 'date_start', 'date_end'])) {
69 69
 					$v = Carbon::parse($v);
70 70
 				}
71 71
 				$this->{$k} = $v;
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 					$this->ownDatastore[] = self::getAssetById($ds->id);
81 81
 				}
82 82
 			}
83
-		}else{
83
+		}else {
84 84
 			$this->__model = new DatastoreModel();
85 85
 		}
86 86
 	}
@@ -92,23 +92,23 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @return void
94 94
 	 */
95
-	public static function getAssetById($id){
95
+	public static function getAssetById($id) {
96 96
 		$datastore = new self($id);
97 97
 		$datastore->setAssetType($datastore->type);
98 98
 		return $datastore;
99 99
 	}
100 100
 
101
-	public static function find($id){
102
-		if(!is_array($id)){
103
-			if(is_object($id)){
101
+	public static function find($id) {
102
+		if (!is_array($id)) {
103
+			if (is_object($id)) {
104 104
 				return self::getAssetById($id->id);
105 105
 			}
106 106
 			return self::getAssetById($id);
107 107
 		}
108 108
 
109
-		if(is_array($id)){
109
+		if (is_array($id)) {
110 110
 			$assets = [];
111
-			foreach($id as $i){
111
+			foreach ($id as $i) {
112 112
 				$assets[] = self::getAssetById($i);
113 113
 			}
114 114
 			return $assets;
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
 	}
130 130
 
131 131
 
132
-	public function ownDatastore(){
133
-		return ($this->ownDatastore)?$this->ownDatastore: array();
132
+	public function ownDatastore() {
133
+		return ($this->ownDatastore) ? $this->ownDatastore : array();
134 134
 	}
135 135
 
136 136
 	/**
@@ -191,9 +191,9 @@  discard block
 block discarded – undo
191 191
 
192 192
 			if (!isset($this->__asset_properties[$p]))
193 193
 			{
194
-				$this->__asset_properties[$p]['temp']					 = self::getAsset($this->__asset->properties[$p]['type']);
194
+				$this->__asset_properties[$p]['temp'] = self::getAsset($this->__asset->properties[$p]['type']);
195 195
 				$this->__asset_properties[$p]['temp']->name				 = (isset($this->__asset->properties[$p]['name'])) ? $this->__asset->properties[$p]['name'] : null;
196
-				$this->__asset_properties[$p]['temp']->key				 = $p;
196
+				$this->__asset_properties[$p]['temp']->key = $p;
197 197
 				$this->__asset_properties[$p]['temp']->private			 = (isset($this->__asset->properties[$p]['private'])) ? $this->__asset->properties[$p]['private'] : false; // accessibility
198 198
 				$this->__asset_properties[$p]['temp']->value			 = (isset($this->__asset->properties[$p]['value'])) ? $this->__asset->properties[$p]['value'] : null; // the actual value of the property
199 199
 				$this->__asset_properties[$p]['temp']->options			 = (isset($this->__asset->properties[$p]['options'])) ? $this->__asset->properties[$p]['options'] : null; // additional options specific to the property
@@ -202,8 +202,8 @@  discard block
 block discarded – undo
202 202
 				$this->__asset_properties[$p]['temp']->help				 = (isset($this->__asset->properties[$p]['help'])) ? $this->__asset->properties[$p]['help'] : null; // additional options specific to the property
203 203
 				$this->__asset_properties[$p]['temp']->required			 = (isset($this->__asset->properties[$p]['required'])) ? $this->__asset->properties[$p]['required'] : true; // is the property required
204 204
 				$this->__asset_properties[$p]['temp']->limit			 = (isset($this->__asset->properties[$p]['limit'])) ? $this->__asset->properties[$p]['limit'] : null; // additional options specific to the property
205
-				$this->__asset_properties[$p]['temp']->warning			 = (isset($this->__asset->properties[$p]['warning'])) ? $this->__asset->properties[$p]['warning'] : null; // additional options specific to the property
206
-				$this->__asset_properties[$p]['temp']->max_instances	 = (isset($this->__asset->properties[$p]['max_instances'])) ? $this->__asset->properties[$p]['max_instances'] : 0; // there can be only one
205
+				$this->__asset_properties[$p]['temp']->warning = (isset($this->__asset->properties[$p]['warning'])) ? $this->__asset->properties[$p]['warning'] : null; // additional options specific to the property
206
+				$this->__asset_properties[$p]['temp']->max_instances = (isset($this->__asset->properties[$p]['max_instances'])) ? $this->__asset->properties[$p]['max_instances'] : 0; // there can be only one
207 207
 			}
208 208
 		}
209 209
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 					$this->__asset_properties[$each->key]	 = array('temp' => $each);
223 223
 					@$this->ownDatastore[$idx]->required		 = (isset($this->__asset->properties[$each->key]['required'])) ? $this->__asset->properties[$each->key]['required'] : true;
224 224
 					@$this->ownDatastore[$idx]->limit		 = (isset($this->__asset->properties[$each->key]['limit'])) ? $this->__asset->properties[$each->key]['limit'] : null;
225
-					@$this->ownDatastore[$idx]->warning		 = (isset($this->__asset->properties[$each->key]['warning'])) ? $this->__asset->properties[$each->key]['warning'] : null;
225
+					@$this->ownDatastore[$idx]->warning = (isset($this->__asset->properties[$each->key]['warning'])) ? $this->__asset->properties[$each->key]['warning'] : null;
226 226
 					@$this->ownDatastore[$idx]->help			 = (isset($this->__asset->properties[$each->key]['help'])) ? $this->__asset->properties[$each->key]['help'] : null;
227 227
 					@$this->ownDatastore[$idx]->max_instances = (isset($this->__asset->properties[$each->key]['max_instances'])) ? $this->__asset->properties[$each->key]['max_instances'] : 0;
228 228
 					@$this->ownDatastore[$idx]->options = (isset($this->__asset->properties[$each->key]['options'])) ? $this->__asset->properties[$each->key]['options'] : null;
@@ -237,19 +237,19 @@  discard block
 block discarded – undo
237 237
 			{
238 238
 
239 239
 				// we need to create a temporary new bean to store new data
240
-				$this->__asset_properties[$prop]['temp']				 = self::getAsset($this->__asset->properties[$prop]['type']);
241
-				$this->__asset_properties[$prop]['temp']->name			 = (isset($this->__asset->properties[$prop]['name'])) ? $this->__asset->properties[$prop]['name'] : null;
242
-				$this->__asset_properties[$prop]['temp']->key			 = $prop;
240
+				$this->__asset_properties[$prop]['temp'] = self::getAsset($this->__asset->properties[$prop]['type']);
241
+				$this->__asset_properties[$prop]['temp']->name = (isset($this->__asset->properties[$prop]['name'])) ? $this->__asset->properties[$prop]['name'] : null;
242
+				$this->__asset_properties[$prop]['temp']->key = $prop;
243 243
 				$this->__asset_properties[$prop]['temp']->private		 = (isset($this->__asset->properties[$prop]['private'])) ? $this->__asset->properties[$prop]['private'] : false; // accessibility
244
-				$this->__asset_properties[$prop]['temp']->value			 = (isset($this->__asset->properties[$prop]['value'])) ? $this->__asset->properties[$prop]['value'] : null; // the actual value of the property
244
+				$this->__asset_properties[$prop]['temp']->value = (isset($this->__asset->properties[$prop]['value'])) ? $this->__asset->properties[$prop]['value'] : null; // the actual value of the property
245 245
 				$this->__asset_properties[$prop]['temp']->options		 = (isset($this->__asset->properties[$prop]['options'])) ? $this->__asset->properties[$prop]['options'] : null; // additional options specific to the property
246 246
 				$this->__asset_properties[$prop]['temp']->callback		 = (isset($this->__asset->properties[$prop]['callback'])) ? $this->__asset->properties[$prop]['callback'] : null; // additional options specific to the property
247 247
 				$this->__asset_properties[$prop]['temp']->meta			 = (isset($this->__asset->properties[$prop]['meta'])) ? $this->__asset->properties[$prop]['meta'] : null; // additional options specific to the property
248 248
 				$this->__asset_properties[$prop]['temp']->help			 = (isset($this->__asset->properties[$prop]['help'])) ? $this->__asset->properties[$prop]['help'] : null; // additional options specific to the property
249 249
 				$this->__asset_properties[$prop]['temp']->required		 = (isset($this->__asset->properties[$prop]['required'])) ? $this->__asset->properties[$prop]['required'] : true; // is the property required
250
-				$this->__asset_properties[$prop]['temp']->limit			 = (isset($this->__asset->properties[$prop]['limit'])) ? $this->__asset->properties[$prop]['limit'] : null; // additional options specific to the property
251
-				$this->__asset_properties[$prop]['temp']->warning		 = (isset($this->__asset->properties[$prop]['warning'])) ? $this->__asset->properties[$prop]['warning'] : null; // additional options specific to the property
252
-				$this->__asset_properties[$prop]['temp']->max_instances	 = (isset($this->__asset->properties[$prop]['max_instances'])) ? $this->__asset->properties[$prop]['max_instances'] : null; // there can be only one
250
+				$this->__asset_properties[$prop]['temp']->limit = (isset($this->__asset->properties[$prop]['limit'])) ? $this->__asset->properties[$prop]['limit'] : null; // additional options specific to the property
251
+				$this->__asset_properties[$prop]['temp']->warning = (isset($this->__asset->properties[$prop]['warning'])) ? $this->__asset->properties[$prop]['warning'] : null; // additional options specific to the property
252
+				$this->__asset_properties[$prop]['temp']->max_instances = (isset($this->__asset->properties[$prop]['max_instances'])) ? $this->__asset->properties[$prop]['max_instances'] : null; // there can be only one
253 253
 
254 254
 			}
255 255
 		}
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 	 */
265 265
 	public static function getKey($string)
266 266
 	{
267
-		$new	 = Helpers::splitByCaps($string);
267
+		$new = Helpers::splitByCaps($string);
268 268
 		$explode = explode(' ', $new);
269 269
 
270 270
 		if (isset($explode[0]) && $explode[0] == 'Ams')
@@ -319,8 +319,8 @@  discard block
 block discarded – undo
319 319
 				break;
320 320
 
321 321
 			case 2:
322
-				$prop	 = func_get_arg(0);
323
-				$val	 = func_get_arg(1);
322
+				$prop = func_get_arg(0);
323
+				$val = func_get_arg(1);
324 324
 				if (isset($this->__asset_properties[$prop]))
325 325
 				{
326 326
 					// check whether this is new or existing
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 				break;
397 397
 
398 398
 			default:
399
-				$val		 = func_get_arg(0);
399
+				$val = func_get_arg(0);
400 400
 				$this->value = $val;
401 401
 		}
402 402
 	}
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 
423 423
 		foreach ($props as $prop)
424 424
 		{
425
-			if (!in_array($prop->name, array('status_equals', 'properties','help','value_equals')))
425
+			if (!in_array($prop->name, array('status_equals', 'properties', 'help', 'value_equals')))
426 426
 			{
427 427
 				$record->{$prop->name} = isset($asset->{$prop->name}) ? $asset->{$prop->name} : NULL;
428 428
 			}
@@ -430,15 +430,15 @@  discard block
 block discarded – undo
430 430
 
431 431
 		if ($asset->__status_equals)
432 432
 		{
433
-			$record->status = isset($record->{$asset->__status_equals})? $record->{$asset->__status_equals} : $this->prop($this->__status_equals);
433
+			$record->status = isset($record->{$asset->__status_equals}) ? $record->{$asset->__status_equals} : $this->prop($this->__status_equals);
434 434
 		}
435 435
 		if ($asset->__start_date)
436 436
 		{
437
-			$record->start_date = isset($record->{$asset->__start_date})? $record->{$asset->__start_date} : $this->prop($this->__start_date);
437
+			$record->start_date = isset($record->{$asset->__start_date}) ? $record->{$asset->__start_date} : $this->prop($this->__start_date);
438 438
 		}
439 439
 		if ($asset->__end_date)
440 440
 		{
441
-			$record->end_date = isset($record->{$asset->__end_date})? $record->{$asset->__end_date} : $this->prop($this->__end_date);
441
+			$record->end_date = isset($record->{$asset->__end_date}) ? $record->{$asset->__end_date} : $this->prop($this->__end_date);
442 442
 		}
443 443
 
444 444
 		$record->options = json_encode($record->options);
@@ -494,8 +494,8 @@  discard block
 block discarded – undo
494 494
 	public function getMarkup($template = false)
495 495
 	{
496 496
 
497
-		$vars				 = $this->export();
498
-		$vars['_unique_id']	 = uniqid();
497
+		$vars = $this->export();
498
+		$vars['_unique_id'] = uniqid();
499 499
 
500 500
 		// we also want to know what asset this property belongs to
501 501
 		$output = Helpers::callStatic($this->type, 'render', array($vars, $template));
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 		if ($this->__status_equals)
529 529
 		{
530 530
 
531
-			$data['status'] = isset($data[$this->__status_equals])? $data[$this->__status_equals] : $this->prop($this->__status_equals);
531
+			$data['status'] = isset($data[$this->__status_equals]) ? $data[$this->__status_equals] : $this->prop($this->__status_equals);
532 532
 		}
533 533
 		if ($this->__start_date)
534 534
 		{
@@ -589,9 +589,9 @@  discard block
 block discarded – undo
589 589
 		}
590 590
 	}
591 591
 
592
-	public function getFieldValues(){
592
+	public function getFieldValues() {
593 593
 		$data = [];
594
-		foreach(array_keys($this->__asset->properties) as $key){
594
+		foreach (array_keys($this->__asset->properties) as $key) {
595 595
 			$data[$key] = $this->prop($key);
596 596
 		}
597 597
 		return $data;
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
 		return $output;
656 656
 	}
657 657
 
658
-	public function propGetValue($prop){
658
+	public function propGetValue($prop) {
659 659
 		dd($prop);
660 660
 	}
661 661
 
@@ -683,8 +683,8 @@  discard block
 block discarded – undo
683 683
 		{
684 684
 			if (isset($this->__asset_properties[$prop]['temp']))
685 685
 			{
686
-				$xvars				 = $this->__asset_properties[$prop]['temp']->export();
687
-				$xvars['unique_id']	 = $unique_id;
686
+				$xvars = $this->__asset_properties[$prop]['temp']->export();
687
+				$xvars['unique_id'] = $unique_id;
688 688
 
689 689
 				$output .= Helpers::callStatic($this->__asset_properties[$prop]['temp']->type, 'form', array($xvars, $this->type));
690 690
 			}
@@ -692,8 +692,8 @@  discard block
 block discarded – undo
692 692
 			{
693 693
 				if (isset($this->__asset_properties[$prop]))
694 694
 				{
695
-					$xvars				 = $this->ownDatastore[$this->__asset_properties[$prop]]->export();
696
-					$xvars['unique_id']	 = $unique_id;
695
+					$xvars = $this->ownDatastore[$this->__asset_properties[$prop]]->export();
696
+					$xvars['unique_id'] = $unique_id;
697 697
 
698 698
 					$output .= Helpers::callStatic($this->ownDatastore[$this->__asset_properties[$prop]]->type, 'form', array($xvars, $this->type));
699 699
 				}
@@ -709,8 +709,8 @@  discard block
 block discarded – undo
709 709
 		return $output;
710 710
 	}
711 711
 
712
-	public function hasMetadataForm(){
713
-		if ($this->namespace == 'asset' && !$this->is_child){
712
+	public function hasMetadataForm() {
713
+		if ($this->namespace == 'asset' && !$this->is_child) {
714 714
 			return ($this->meta_description !== 'off' || $this->meta_keywords !== 'off');
715 715
 		}
716 716
 		return false;
@@ -757,8 +757,8 @@  discard block
 block discarded – undo
757 757
 		return $output;
758 758
 	}
759 759
 
760
-	public function hasDeveloperForm(){
761
-		if ($this->namespace == 'asset' && !$this->is_child){
760
+	public function hasDeveloperForm() {
761
+		if ($this->namespace == 'asset' && !$this->is_child) {
762 762
 			return ($this->page_js !== 'off' || $this->page_css !== 'off');
763 763
 		}
764 764
 		return false;
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
 				$output .= Helpers::callStatic(ASSET::METATEXT, 'form', array($data, 'metatext'));
787 787
 			}
788 788
 
789
-			if ($this->page_js !== 'off' )
789
+			if ($this->page_js !== 'off')
790 790
 			{
791 791
 				$data = array(
792 792
 					'name'		 => 'Custom JS',
@@ -817,11 +817,11 @@  discard block
 block discarded – undo
817 817
 		$messages = array();
818 818
 		foreach ($this->__asset->properties as $key => $property)
819 819
 		{
820
-			if($property['type'] !== \Phpsa\Datastore\Ams\AutoCallBackAdderAsset::class && (empty($property['required']) || $property['required'] === true) )
820
+			if ($property['type'] !== \Phpsa\Datastore\Ams\AutoCallBackAdderAsset::class && (empty($property['required']) || $property['required'] === true))
821 821
 			{
822 822
 				$rules = empty($property['validation_rules']) ? 'required' : $property['validation_rules'];
823
-				if(!empty($property['validation_messages'])){
824
-					if(is_string($property['validation_messages'])){
823
+				if (!empty($property['validation_messages'])) {
824
+					if (is_string($property['validation_messages'])) {
825 825
 						$messages[$key . '.required'] = $property['validation_messages'];
826 826
 					}
827 827
 				}
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 		{
835 835
 			$validator = Validator::make($request, $config, $messages);
836 836
 
837
-			if($validator->fails()){
837
+			if ($validator->fails()) {
838 838
 				throw new ValidationException($validator);
839 839
 			}
840 840
 		}
@@ -990,9 +990,9 @@  discard block
 block discarded – undo
990 990
 	 */
991 991
 	public function statusIsActive() :bool
992 992
 	{
993
-		if($this->__status_equals){
993
+		if ($this->__status_equals) {
994 994
 
995
-			if(!isset($this->__asset->properties[$this->__status_equals]['published'])){
995
+			if (!isset($this->__asset->properties[$this->__status_equals]['published'])) {
996 996
 				throw new DatastoreException("Statused assests need a published option in the asset definition");
997 997
 			}
998 998
 
Please login to merge, or discard this patch.
src/Http/Controllers/DatastoreController.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -17,17 +17,17 @@
 block discarded – undo
17 17
 	/**
18 18
 	 * @var DatastoreRepository
19 19
 	 */
20
-    protected $datastoreRepository;
20
+	protected $datastoreRepository;
21 21
 
22
-    /**
23
-     * UserController constructor.
24
-     *
25
-     * @param DatastoreRepository $datastoreRepository
22
+	/**
23
+	 * UserController constructor.
24
+	 *
25
+	 * @param DatastoreRepository $datastoreRepository
26 26
 	 * @todo get rid of these datastoreRepository and make use of the mode only
27
-     */
28
-    public function __construct(DatastoreRepository $datastoreRepository)
29
-    {
30
-        $this->datastoreRepository = $datastoreRepository;
27
+	 */
28
+	public function __construct(DatastoreRepository $datastoreRepository)
29
+	{
30
+		$this->datastoreRepository = $datastoreRepository;
31 31
 	}
32 32
 
33 33
 	/**
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -52,16 +52,16 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @return DatastorePages
54 54
 	 */
55
-	protected function getPageBySlug($slug){
55
+	protected function getPageBySlug($slug) {
56 56
 		$page = DatastorePages::where('slug', $slug)->first();
57
-		if(!$page){
57
+		if (!$page) {
58 58
 			abort(404);
59 59
 		}
60 60
 
61 61
 		$datastore = $page->datastore;
62 62
 		$user = auth()->user();
63 63
 
64
-		if(!$datastore->statusIsActive() && (!$user || !$user->can('manage datastore'))) {
64
+		if (!$datastore->statusIsActive() && (!$user || !$user->can('manage datastore'))) {
65 65
 			abort(404);
66 66
 		}
67 67
 		return $page;
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory
76 76
 	 */
77
-	public function page($slug){
77
+	public function page($slug) {
78 78
 
79 79
 		$page = $this->getPageBySlug($slug);
80 80
 
@@ -88,11 +88,11 @@  discard block
 block discarded – undo
88 88
 
89 89
 	}
90 90
 
91
-	public function childPage($parent_slug, $slug){
91
+	public function childPage($parent_slug, $slug) {
92 92
 		return $this->page($slug);
93 93
 	}
94 94
 
95
-	public function articleByAuthor($author_id, $slug){
95
+	public function articleByAuthor($author_id, $slug) {
96 96
 		$this->datastoreRepository->paginateSearchProp('author', $author_id, Phpsa\Datastore\Ams\Article\ItemAsset::class, $this->canViewAll('published'));
97 97
 	}
98 98
 
Please login to merge, or discard this patch.