Skip to content
Newer
Older
100644 71 lines (52 sloc) 1 KB
7f13ef8 @mageekguy Use registry, improve assertion fail backtracking, improve unit test …
authored Oct 25, 2010
1 <?php
2
3 namespace mageekguy\atoum;
4
e88ce0e @mageekguy Use decorators in writer, close #263.
authored Sep 20, 2013
5 use
6 mageekguy\atoum\writer\decorator
7 ;
8
f20d309 @mageekguy Remove useless interface.
authored Oct 31, 2012
9 abstract class writer
7f13ef8 @mageekguy Use registry, improve assertion fail backtracking, improve unit test …
authored Oct 25, 2010
10 {
11 protected $adapter = null;
e88ce0e @mageekguy Use decorators in writer, close #263.
authored Sep 20, 2013
12 protected $decorators = array();
7f13ef8 @mageekguy Use registry, improve assertion fail backtracking, improve unit test …
authored Oct 25, 2010
13
14 public function __construct(adapter $adapter = null)
15 {
7179775 @mageekguy Cleaning.
authored May 16, 2013
16 $this->setAdapter($adapter);
7f13ef8 @mageekguy Use registry, improve assertion fail backtracking, improve unit test …
authored Oct 25, 2010
17 }
18
7179775 @mageekguy Cleaning.
authored May 16, 2013
19 public function setAdapter(adapter $adapter = null)
7f13ef8 @mageekguy Use registry, improve assertion fail backtracking, improve unit test …
authored Oct 25, 2010
20 {
7179775 @mageekguy Cleaning.
authored May 16, 2013
21 $this->adapter = $adapter ?: new adapter();
7f13ef8 @mageekguy Use registry, improve assertion fail backtracking, improve unit test …
authored Oct 25, 2010
22
23 return $this;
24 }
25
26 public function getAdapter()
27 {
28 return $this->adapter;
29 }
30
587a130 @mageekguy Avoid deadlock in writer.
authored Aug 6, 2013
31 public function reset()
32 {
33 return $this;
34 }
35
e88ce0e @mageekguy Use decorators in writer, close #263.
authored Sep 20, 2013
36 public function addDecorator(decorator $decorator)
37 {
38 $this->decorators[] = $decorator;
39
40 return $this;
41 }
42
43 public function getDecorators()
44 {
45 return $this->decorators;
46 }
47
21aa94a @mageekguy All decorators of output writer are removed before writing.
authored Nov 12, 2013
48 public function removeDecorators()
49 {
50 $this->decorators = array();
51
52 return $this;
53 }
54
e88ce0e @mageekguy Use decorators in writer, close #263.
authored Sep 20, 2013
55 public function write($string)
56 {
57 foreach ($this->decorators as $decorator)
58 {
59 $string = $decorator->decorate($string);
60 }
61
62 $this->doWrite($string);
63
64 return $this;
65 }
66
f312ac9 @mageekguy Add clear() in writers.
authored Dec 30, 2011
67 public abstract function clear();
e88ce0e @mageekguy Use decorators in writer, close #263.
authored Sep 20, 2013
68
69 protected abstract function doWrite($string);
67c8b0d @mageekguy Remove 'no new line at end of file' message.
authored Jun 23, 2012
70 }
Something went wrong with that request. Please try again.