1 | <?php |
||
15 | class Jsonp extends AbstractOutput |
||
16 | { |
||
17 | |||
18 | /** |
||
19 | * {@inheritdoc} |
||
20 | * @see http://www.rfc-editor.org/rfc/rfc4329.txt |
||
21 | */ |
||
22 | protected $content_type = 'application/javascript'; |
||
23 | |||
24 | /** |
||
25 | * {@inheritdoc} |
||
26 | */ |
||
27 | public function encode(array $data, $rootNode=null) |
||
45 | |||
46 | /** |
||
47 | * Check wether a callback string name is a valid javascript identifier. |
||
48 | * @see http://www.geekality.net/2011/08/03/valid-javascript-identifier/ |
||
49 | * @see http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf |
||
50 | * |
||
51 | * @param string $subject |
||
52 | * @return boolean |
||
53 | */ |
||
54 | public function isValidIdentifier($subject) |
||
69 | } |
||
70 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: