FailureExample.php 951 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * This file is part of vfsStream.
  4. *
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. *
  8. * @package org\bovigo\vfs
  9. */
  10. namespace org\bovigo\vfs\example;
  11. /**
  12. * Example class to demonstrate testing of failure behaviour with vfsStream.
  13. */
  14. class FailureExample
  15. {
  16. /**
  17. * filename to write data
  18. *
  19. * @type string
  20. */
  21. protected $filename;
  22. /**
  23. * constructor
  24. *
  25. * @param string $id
  26. */
  27. public function __construct($filename)
  28. {
  29. $this->filename = $filename;
  30. }
  31. /**
  32. * sets the directory
  33. *
  34. * @param string $directory
  35. */
  36. public function writeData($data)
  37. {
  38. $bytes = @file_put_contents($this->filename, $data);
  39. if (false === $bytes) {
  40. return 'could not write data';
  41. }
  42. return 'ok';
  43. }
  44. // more source code here...
  45. }
  46. ?>