-
Notifications
You must be signed in to change notification settings - Fork 1
/
Example.php
103 lines (88 loc) · 2.71 KB
/
Example.php
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
<?php
/**
* @author stev leibelt <artodeto@arcor.de>
* @since 2013-08-12
*/
namespace Example\Validator;
require __DIR__ . '/../../../../vendor/autoload.php';
Example::create()
->setup()
->andRun();
/**
* Class Example
*
* @package Example\Validator
* @author stev leibelt <artodeto@arcor.de>
* @since 2013-08-12
*/
class Example
{
/**
* @var \Net\Bazzline\Component\Requirement\Requirement
* @author stev leibelt <artodeto@arcor.de>
* @since 2013-08-12
*/
private $validator;
/**
* @var Table[]
* @author stev leibelt <artodeto@arcor.de>
* @since 2013-08-12
*/
private $tables;
/**
* @return Example
* @author stev leibelt <artodeto@arcor.de>
* @since 2012-08-12
*/
public static function create()
{
return new self();
}
/**
* @return $this
* @author stev leibelt <artodeto@arcor.de>
* @since 2013-08-12
*/
public function setup()
{
$this->validator = TableValidatorCollection::create();
$this->tables = array();
$colors = array(0 => 'red', 1 => 'green', 2 => 'blue', 3 => 'yellow', 4 => 'orange', 5 => 'black');
$heights = array(0 => 50, 1 => 69, 2 => 70, 3 => 74, 4 => 81, 5 => 85, 6 => 89, 7 => 101);
$lengths = array(0 => 40, 1 => 56, 2 => 71, 3 => 91, 4 => 100, 5 => 200, 6 => 210);
$widths = array(0 => 47, 1 => 76, 2 => 82, 3 => 129, 4 => 132, 5 => 154, 6 => 179);
$sizeOfColors = count($colors) - 1;
$sizeOfHeight = count($heights) - 1;
$sizeOfLengths = count($lengths) - 1;
$sizeOfWidths = count($widths) - 1;
$numberOfTables = 7;
for ($iterator = 0; $iterator < $numberOfTables; $iterator++) {
$table = new Table();
$table->setColor($colors[rand(0, $sizeOfColors)]);
$table->setHeight($heights[rand(0, $sizeOfHeight)]);
$table->setLength($lengths[rand(0, $sizeOfLengths)]);
$table->setWidth($widths[rand(0, $sizeOfWidths)]);
$this->tables[] = $table;
}
return $this;
}
/**
* @author stev leibelt <artodeto@arcor.de>
* @since 2013-08-12
*/
public function andRun()
{
echo str_repeat('-', 48) . PHP_EOL;
echo 'Number of tables: ' . count($this->tables) . PHP_EOL;
echo str_repeat('-', 48) . PHP_EOL;
echo 'Iterating over tables.' . PHP_EOL;
foreach ($this->tables as $table) {
/**
* @var Table $table
*/
$this->validator->setTable($table);
echo 'Is valid table: ' . ($this->validator->isMet() ? 'yes' : 'no') . PHP_EOL;
}
echo str_repeat('-', 48) . PHP_EOL;
}
}