Skip to content

Commit 1c6a877

Browse files
author
Damien Debin
committed
Reworked examples.
1 parent f8b85e9 commit 1c6a877

File tree

8 files changed

+55
-33
lines changed

8 files changed

+55
-33
lines changed

examples/callback_fields.php

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
<?php
2+
23
/** @noinspection PhpUnhandledExceptionInspection */
3-
require_once __DIR__.'/init.php';
44

5-
if (isset($_GET['tq'])) {
6-
function most_common($row)
7-
{
8-
$forms = ['pill', 'iud', 'condom', 'sterile_total', 'other_modern', 'traditional'];
9-
$max_form = -1;
10-
$form_name = null;
11-
foreach ($forms as $form) {
12-
if ($row[$form] > $max_form) {
13-
$max_form = $row[$form];
14-
$form_name = $form;
15-
}
16-
}
5+
use MC\Google\Visualization;
176

18-
return $form_name;
7+
require_once __DIR__.'/../vendor/autoload.php';
8+
9+
function most_common($row)
10+
{
11+
$forms = ['pill', 'iud', 'condom', 'sterile_total', 'other_modern', 'traditional'];
12+
$max_form = -1;
13+
$form_name = null;
14+
foreach ($forms as $form) {
15+
if ($row[$form] > $max_form) {
16+
$max_form = $row[$form];
17+
$form_name = $form;
18+
}
1919
}
2020

21+
return $form_name;
22+
}
23+
24+
$db = new PDO('sqlite:example.db');
25+
26+
$vis = new Visualization($db);
27+
28+
if (isset($_GET['tq'])) {
2129
$vis->addEntity('birth_control', [
2230
'fields' => [
2331
'country' => ['field' => 'c.name', 'type' => 'text', 'join' => 'country'],

examples/complete.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<?php
2+
23
/** @noinspection PhpUnhandledExceptionInspection */
3-
require_once __DIR__.'/init.php';
4+
5+
use MC\Google\Visualization;
6+
7+
require_once __DIR__.'/../vendor/autoload.php';
8+
9+
$db = new PDO('sqlite:example.db');
10+
11+
$vis = new Visualization($db);
412

513
if (isset($_GET['tq'])) {
614
$vis->addEntity('timeline', [

examples/init.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

examples/joins.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<?php
2+
23
/** @noinspection PhpUnhandledExceptionInspection */
3-
require_once __DIR__.'/init.php';
4+
5+
use MC\Google\Visualization;
6+
7+
require_once __DIR__.'/../vendor/autoload.php';
8+
9+
$db = new PDO('sqlite:example.db');
10+
11+
$vis = new Visualization($db);
412

513
if (isset($_GET['tq'])) {
614
$vis->addEntity('countries', [

examples/simple.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<?php
2+
23
/** @noinspection PhpUnhandledExceptionInspection */
3-
require_once __DIR__.'/init.php';
4+
5+
use MC\Google\Visualization;
6+
7+
require_once __DIR__.'/../vendor/autoload.php';
8+
9+
$db = new PDO('sqlite:example.db');
10+
11+
$vis = new Visualization($db);
412

513
if (isset($_GET['tq'])) {
614
$vis->addEntity('countries', [

tests/ExampleTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ protected function setUp()
1616
parent::setUp();
1717

1818
// cf. https://stackoverflow.com/a/46390357/377645
19-
ini_set('precision', 15);
20-
ini_set('serialize_precision', -1);
19+
ini_set('precision', '15');
20+
ini_set('serialize_precision', '-1');
2121
}
2222

2323
/**

tests/ParserTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ protected function setUp()
1717
parent::setUp();
1818

1919
// cf. https://stackoverflow.com/a/46390357/377645
20-
ini_set('precision', 15);
21-
ini_set('serialize_precision', -1);
20+
ini_set('precision', '15');
21+
ini_set('serialize_precision', '-1');
2222
}
2323

2424
/**

tests/VisualizationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ protected function setUp()
2020
parent::setUp();
2121

2222
// cf. https://stackoverflow.com/a/46390357/377645
23-
ini_set('precision', 15);
24-
ini_set('serialize_precision', -1);
23+
ini_set('precision', '15');
24+
ini_set('serialize_precision', '-1');
2525
}
2626

2727
/**

0 commit comments

Comments
 (0)