summaryrefslogtreecommitdiff
path: root/vendor/zordius/lightncandy/tests/helpers_for_test.php
blob: 80c3e860ad3cd3760c1ec2caa808ed26ccde72cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php

// Class for customized LCRun
class MyLCRunClass extends LCRun3 {
    public static function raw($cx, $v) {
        return '[[DEBUG:raw()=>' . var_export($v, true) . ']]';
    }
}

// Classes for inputs or helpers
class myClass {
    function test() {
        return 'testMethod OK!';
    }

    function helper2($arg) {
        return is_array($arg) ? '=Array=' : "=$arg=";
    }

    function __call($method, $args) {
        return "-- $method:" . print_r($args, true);
    }
}

class foo {
    public $prop = 'Yes!';

    function bar() {
        return 'OK!';
    }
}

class twoDimensionIterator implements Iterator {
    private $position = 0;
    private $x = 0;
    private $y = 0;
    private $w = 0;
    private $h = 0;

    public function __construct($w, $h) {
        $this->w = $w;
        $this->h = $h;
        $this->rewind();
    }

    function rewind() {
        $this->position = 0;
        $this->x = 0;
        $this->y = 0;
    }

    function current() {
        return $this->x * $this->y;
    }

    function key() {
        return $this->x . 'x' . $this->y;
    }

    function next() {
        ++$this->position;
        $this->x = $this->position % $this->w;
        $this->y = floor($this->position / $this->w);
    }

    function valid() {
        return $this->position < $this->w * $this->h;
    }
}

// Custom helpers
function helper1($arg) {
    $arg = is_array($arg) ? 'Array' : $arg;
    return "-$arg-";
}                                                                                                                                          
function alink($u, $t) {
    $u = is_array($u) ? 'Array' : $u;
    $t = is_array($t) ? 'Array' : $t;
    return "<a href=\"$u\">$t</a>";
}

 function meetup_date_format() {
    return "OKOK~1";
}

function  meetup_date_format2() {
    return "OKOK~2";
}

function        meetup_date_format3 () {
    return "OKOK~3";
}

function	meetup_date_format4(){
    return "OKOK~4";};


function test_array ($input) {
   return is_array($input[0]) ? 'IS_ARRAY' : 'NOT_ARRAY';
}

function test_join ($input) {
   return join('.', $input[0]);
}

// Custom helpers for handlebars (should be used in hbhelpers)
function myif ($conditional, $options) {
    if ($conditional) {
        return $options['fn']();
    } else {
        return $options['inverse']();
    }
}

function mywith ($context, $options) {
    return $options['fn']($context);
}

function myeach ($context, $options) {
    $ret = '';
    foreach ($context as $cx) {
        $ret .= $options['fn']($cx);
    }
    return $ret;
}

function mylogic ($input, $yes, $no, $options) {
    if ($input === true) {
        return $options['fn']($yes);
    } else {
        return $options['inverse']($no);
    }
}

function mydash ($a, $b) {
    return "$a-$b";
}

function myjoin ($a, $b) {
    return "$a$b";
}

function getroot ($options) {
    return $options['data']['root'];
}

?>