4 * Provides a custom registered stream for use with a transport protocol
5 * This is part of the Swift Mailer unit testing stuff.
6 * It uses a command processor to do that actual reading/writing
11 * The command processor
12 * @var object singleton processor
17 * PHP's call back for fopen() actions on the fake stream
19 public function stream_open($path, $mode, $options, &$opened_path)
21 $this->processor
= Swift_Stream_Processor
::getInstance();
22 $this->processor
->isOpen
= true;
23 return $this->processor
->isOpen
;
26 * PHP Callback for fread() fgets() etc
28 public function stream_read($size)
30 return $this->processor
->getResponse($size);
35 public function stream_write($string)
37 if ($this->processor
->isOpen
)
39 $this->processor
->setCommand($string);
40 return strlen($string);
45 * Only here to prevent errors
47 public function stream_eof()
49 //Does nothing... SMTP doesn't implement it
50 // It's vital we can work this out ourselves
53 * Singletons never really get destroyed much, this just nulls it out
55 public function stream_close()
57 $this->processor
->destroy();
61 //Registers a stream which can be accessed as swift://url
62 stream_wrapper_register('swift', 'Swift_Stream');