1: <?php
2:
3: namespace PHPixie\Debug;
4:
5: class Builder
6: {
7: protected $instances = array();
8:
9: public function dumper()
10: {
11: return $this->instance('dumper');
12: }
13:
14: public function handlers()
15: {
16: return $this->instance('handlers');
17: }
18:
19: public function logger()
20: {
21: return $this->instance('logger');
22: }
23:
24: public function messages()
25: {
26: return $this->instance('messages');
27: }
28:
29: public function tracer()
30: {
31: return $this->instance('tracer');
32: }
33:
34: public function loggerItem($traceElement, $value, $shortDumpByDefault = false)
35: {
36: return new Logger\Item(
37: $this->dumper(),
38: $traceElement,
39: $value,
40: $shortDumpByDefault
41: );
42: }
43:
44: public function trace($elements = array())
45: {
46: return new Tracer\Trace($elements);
47: }
48:
49: public function traceElement(
50: $file = null,
51: $line = null,
52: $functionName = null,
53: $arguments = null,
54: $className = null,
55: $object = null,
56: $type = null
57: )
58: {
59: return new Tracer\Trace\Element(
60: $this->dumper(),
61: $file,
62: $line,
63: $functionName,
64: $arguments,
65: $className,
66: $object,
67: $type
68: );
69: }
70:
71: protected function instance($name)
72: {
73: if(!array_key_exists($name, $this->instances)) {
74: $method = 'build'.ucfirst($name);
75: $this->instances[$name] = $this->$method();
76: }
77:
78: return $this->instances[$name];
79: }
80:
81: protected function buildDumper()
82: {
83: return new Dumper();
84: }
85:
86: protected function buildHandlers()
87: {
88: return new Handlers($this);
89: }
90:
91: protected function buildLogger()
92: {
93: return new Logger($this);
94: }
95:
96: protected function buildMessages()
97: {
98: return new Messages($this);
99: }
100:
101: protected function buildTracer()
102: {
103: return new Tracer($this);
104: }
105: }