1 <?php
2 require( '../Kint.class.php' );
3
4 $selectedTheme = isset( $_GET['theme'] ) ? $_GET['theme'] : 'original';
5 $allowedThemes = array();
6 $dh = opendir( '../view/compiled' );
7 while ( ( $filename = readdir( $dh ) ) !== false ) {
8 if ( strpos( $filename, '.css' ) !== false ) {
9 $allowedThemes[] = str_replace( '.css', '', $filename );
10 }
11 }
12
13 sort( $allowedThemes );
14
15 if ( in_array( $selectedTheme, $allowedThemes ) ) {
16 Kint::$theme = $selectedTheme;
17 }
18
19 class BaseUser
20 {
21 22 23
24 public function getFullName() { }
25 }
26
27 class User extends BaseUser
28 {
29 CONST DEFAULT_PATH = 'some/default/path';
30 CONST ROLE_DISALLOWED = 1;
31 CONST ROLE_ALLOWED = 2;
32 CONST ROLE_FORBIDDEN = 3;
33
34 public $additionalData;
35 private $username = 'demo_username';
36 private $password = 'demo_password';
37 private $createdDate;
38
39 public function __construct() { }
40
41 42 43
44 public function isEqualTo( BaseUser $user ) { }
45
46 47 48 49 50 51 52
53 public function setUsername( $username ) { }
54
55 56 57 58 59
60 public function setAdditionalData( array $data ) { $this->additionalData = $data; }
61
62 63 64
65 public function getCreatedDate() { }
66
67 68 69
70 public function setCreatedDate( DateTime $date ) { $this->createdDate = $date; }
71
72 73 74
75 public function ensure() { Kint::trace(); }
76 }
77
78 class UserManager
79 {
80 private $user;
81
82 83 84
85 public function getUser() { return $this->user; }
86
87 88 89 90 91
92 public function debugUser( $user )
93 {
94 $this->user = $user;
95 d( $this->getUser() );
96 }
97
98 99 100 101 102
103 public function ensureUser() { $this->user->ensure(); }
104 }
105
106 $user = new User;
107 $user->setAdditionalData( array(
108 'last_login' => new DateTime(),
109 'current_unix_timestamp' => time(),
110 'random_rgb_color_code' => '#FF9900',
111 'impressions' => 60,
112 'nickname' => 'Someuser',
113 )
114 );
115 $user->setCreatedDate( new DateTime( '2013-10-10' ) );
116 $userManager = new UserManager();
117
118 for ( $i = 1; $i < 6; $i++ ) {
119 $tabularData[] = array(
120 'date' => "2013-01-0{$i}",
121 'allowed' => $i % 3 == 0,
122 'action' => "action {$i}",
123 'clicks' => rand( 100, 50000 ),
124 'impressions' => rand( 10000, 500000 ),
125 );
126
127 if ( $i % 2 == 0 ) {
128 unset( $tabularData[ $i - 1 ]['clicks'] );
129 }
130 }
131
132 $nestedArray = array();
133
134 for ( $i = 1; $i < 6; $i++ ) {
135 $nestedArray["user group {$i}"] = array(
136 "user {$i}" => array(
137 'name' => "Name {$i}",
138 'surname' => "Surname {$i}"
139 ),
140
141 'data' => array(
142 'conversions' => rand( 100, 5000 ),
143 'spent' => array( 'currency' => 'EUR', 'amount' => rand( 10000, 500000 ) )
144 ),
145 );
146 }
147 ?>
148 <html>
149 <head>
150 <title>Kint PHP debugging tool - overview</title>
151 </head>
152 <body>
153 <div>
154 <label style="float: right">Switch theme:
155 <select onchange="window.location = '?theme=' + this.value">
156 <?php $chosen = isset( $_GET['theme'] ) ? $_GET['theme'] : 'original' ?>
157 <?php foreach ( $allowedThemes as $theme ) : ?>
158 <option value="<?php echo $theme ?>"<?php echo $theme === $chosen ? ' selected' : '' ?>>
159 <?php echo ucfirst( str_replace( '-', ' ', $theme ) ) ?>
160 </option>
161 <?php endforeach ?>
162 </select>
163 </label>
164
165 <h2>Kint PHP debugging tool - overview</h2>
166 </div>
167 <h3>Debug variables</h3>
168 <?php
169 $userManager->debugUser( $user );
170 d( $userManager, $tabularData );
171 d( $nestedArray );
172 ?>
173 <h3>Trace</h3>
174 <?php $userManager->ensureUser(); ?>
175 </body>
176 </html>