FilemodeExample.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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.
  13. */
  14. class FilemodeExample
  15. {
  16. /**
  17. * id of the example
  18. *
  19. * @type string
  20. */
  21. protected $id;
  22. /**
  23. * a directory where we do something..
  24. *
  25. * @type string
  26. */
  27. protected $directory;
  28. /**
  29. * file mode for newly created directories
  30. *
  31. * @type int
  32. */
  33. protected $fileMode;
  34. /**
  35. * constructor
  36. *
  37. * @param string $id
  38. * @param int $fileMode optional
  39. */
  40. public function __construct($id, $fileMode = 0700)
  41. {
  42. $this->id = $id;
  43. $this->fileMode = $fileMode;
  44. }
  45. /**
  46. * sets the directory
  47. *
  48. * @param string $directory
  49. */
  50. public function setDirectory($directory)
  51. {
  52. $this->directory = $directory . DIRECTORY_SEPARATOR . $this->id;
  53. if (file_exists($this->directory) === false) {
  54. mkdir($this->directory, $this->fileMode, true);
  55. }
  56. }
  57. // more source code here...
  58. }
  59. ?>