AjaxExample::get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 13
rs 9.4285
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
/**
3
 * Examples Controller
4
 * Multiple examples of how you can use erdiko.  It includes some simple use cases.
5
 *
6
 * @category    app
7
 * @package     controllers
8
 * @copyright   Copyright (c) 2016, Arroyo Labs, www.arroyolabs.com
9
 * @author      John Arroyo, [email protected]
10
 */
11
namespace app\controllers;
12
13
14
/**
15
 * AjaxExample Class
16
 */
17
class AjaxExample extends \erdiko\core\AjaxController
18
{
19
	
20
	/**
21
     * Get
22
     */
23
	public function get($var = null)
24
	{
25
		if($var != null)
26
		{
27
			// load action
28
			return $this->_autoaction($var);
29
		}
30
31
		$data = array("hello", "world");
32
		$view = new \erdiko\core\View('examples/helloworld', $data);
33
		
34
		$this->setContent($view);
35
	}
36
37
	/**
38
   	 * Get Example
39
   	 */
40
	public function getExample()
41
	{
42
		$content = array(
43
			'hello' => 'world',
44
			'ajax' => 'rocks'
45
			);
46
47
		$this->setContent($content);
0 ignored issues
show
Documentation introduced by
$content is of type array<string,string,{"he...ring","ajax":"string"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
48
	}
49
50
}
51