Overview
Namespaces
Classes
Exceptions
1: <?php
2:
3: /**
4: * XSLT Benchmarking
5: * @link https://github.com/masicek/XSLT-Benchmarking
6: * @author Viktor Mašíček <viktor@masicek.net>
7: * @license "New" BSD License
8: */
9:
10: namespace XSLTBenchmarking;
11:
12: /**
13: * Printing information text
14: *
15: * @author Viktor Mašíček <viktor@masicek.net>
16: */
17: class Printer
18: {
19:
20:
21: /**
22: * Constant for production mode of printing
23: */
24: const MODE_PRODUCTION = 'production';
25:
26: /**
27: * Constant for production mode of printing
28: */
29: const MODE_TEST = 'test';
30:
31: /**
32: * Selected mode of printing
33: *
34: * @var string
35: */
36: public static $mode = self::MODE_PRODUCTION;
37:
38:
39: /**
40: * Make this class static
41: *
42: * @codeCoverageIgnore
43: */
44: private function __construct()
45: {
46: }
47:
48:
49: /**
50: * Print header
51: *
52: * @param string $header Text of printed header
53: *
54: * @return void
55: */
56: public static function header($header)
57: {
58: $header = $header . ':';
59: $line = str_repeat('-', strlen($header));
60: self::info($header);
61: self::info($line);
62: }
63:
64:
65: /**
66: * Print information text
67: *
68: * @param string $info Text of printed info
69: *
70: * @return void
71: */
72: public static function info($info = '')
73: {
74: switch (self::$mode)
75: {
76: case self::MODE_PRODUCTION:// @codeCoverageIgnoreStart
77: fwrite(STDOUT, $info . PHP_EOL);
78: break;// @codeCoverageIgnoreEnd
79:
80: case self::MODE_TEST:
81: echo $info . PHP_EOL;
82: break;
83: }
84: }
85:
86: }
87: