@@ 23-68 (lines=46) @@ | ||
20 | * |
|
21 | * @author Simon Ball <simonball at simonball dot me> |
|
22 | */ |
|
23 | class ReportPattern |
|
24 | { |
|
25 | ||
26 | ||
27 | private $patterns = array(); |
|
28 | ||
29 | /** |
|
30 | * Add an extra patter object to the stack for later use |
|
31 | * |
|
32 | * @param PatternInterface $pattern |
|
33 | * @param string $alias |
|
34 | */ |
|
35 | public function addPattern(PatternInterface $pattern, $alias) |
|
36 | { |
|
37 | $this->patterns[$alias] = $pattern; |
|
38 | } |
|
39 | ||
40 | /** |
|
41 | * A front-end for running pattern operations that are loaded on to the stack |
|
42 | * |
|
43 | * @param string $alias |
|
44 | * @param ReportBuilder $context |
|
45 | * @return boolean Success condition |
|
46 | * @throws \Exception when pattern not available |
|
47 | */ |
|
48 | public function run($alias, ReportBuilder &$context) |
|
49 | { |
|
50 | if (isset($this->patterns[$alias])) { |
|
51 | $this->patterns[$alias]->run($context); |
|
52 | ||
53 | return true; |
|
54 | } else { |
|
55 | throw new \Exception('Report pattern is not registered: ' . $alias); |
|
56 | } |
|
57 | } |
|
58 | ||
59 | /** |
|
60 | * Get a simple array list of the currently loaded pattern objects |
|
61 | * |
|
62 | * @return array |
|
63 | */ |
|
64 | public function getPatternsLoaded() |
|
65 | { |
|
66 | return array_keys($this->patterns); |
|
67 | } |
|
68 | } |
|
69 |
@@ 23-69 (lines=47) @@ | ||
20 | * |
|
21 | * @author Simon Ball <simonball at simonball dot me> |
|
22 | */ |
|
23 | class ReportStyle |
|
24 | { |
|
25 | private $styles = array(); |
|
26 | ||
27 | /** |
|
28 | * Add an extra styler object to the stack for later use |
|
29 | * |
|
30 | * @param StyleInterface $style |
|
31 | * @param string $alias |
|
32 | */ |
|
33 | public function addStyle(StyleInterface $style, $alias) |
|
34 | { |
|
35 | $this->styles[$alias] = $style; |
|
36 | } |
|
37 | ||
38 | /** |
|
39 | * A front-end for running style operations that are loaded on to the stack |
|
40 | * |
|
41 | * @param string $alias |
|
42 | * @param ReportBuilder $context |
|
43 | * @param string $coordString |
|
44 | * @param array $options |
|
45 | * @return boolean Success condition |
|
46 | * @throws \Exception when style function not available |
|
47 | */ |
|
48 | public function run($alias, ReportBuilder &$context, $coordString, $options = array()) |
|
49 | { |
|
50 | ||
51 | if (isset($this->styles[$alias])) { |
|
52 | $this->styles[$alias]->run($context, $coordString, $options); |
|
53 | ||
54 | return true; |
|
55 | } else { |
|
56 | throw new \Exception('Report style is not registered: ' . $alias); |
|
57 | } |
|
58 | } |
|
59 | ||
60 | /** |
|
61 | * Get a simple array list of the currently loaded style objects |
|
62 | * |
|
63 | * @return array |
|
64 | */ |
|
65 | public function getStylesLoaded() |
|
66 | { |
|
67 | return array_keys($this->styles); |
|
68 | } |
|
69 | } |
|
70 |
@@ 22-66 (lines=45) @@ | ||
19 | * |
|
20 | * @author Simon Ball <simonball at simonball dot me> |
|
21 | */ |
|
22 | class ReportQuery |
|
23 | { |
|
24 | ||
25 | ||
26 | private $queries = array(); |
|
27 | ||
28 | /** |
|
29 | * Add an extra patter object to the stack for later use |
|
30 | * |
|
31 | * @param QueryInterface $query |
|
32 | * @param string $alias |
|
33 | */ |
|
34 | public function addQuery(QueryInterface $query, $alias) |
|
35 | { |
|
36 | $this->queries[$alias] = $query; |
|
37 | } |
|
38 | ||
39 | /** |
|
40 | * A front-end for running pattern operations that are loaded on to the stack |
|
41 | * |
|
42 | * @param string $alias |
|
43 | * @param ReportBuilder $context |
|
44 | * @return boolean Success condition |
|
45 | * @throws \Exception when pattern not available |
|
46 | */ |
|
47 | public function get($alias) |
|
48 | { |
|
49 | if (isset($this->queries[$alias])) { |
|
50 | ||
51 | return $this->queries[$alias]; |
|
52 | } else { |
|
53 | throw new \Exception('Query type is not registered: ' . $alias); |
|
54 | } |
|
55 | } |
|
56 | ||
57 | /** |
|
58 | * Get a simple array list of the currently loaded pattern objects |
|
59 | * |
|
60 | * @return array |
|
61 | */ |
|
62 | public function getQueriesLoaded() |
|
63 | { |
|
64 | return array_keys($this->queries); |
|
65 | } |
|
66 | } |
|
67 |