Guest User

Untitled

a guest
Jan 19th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. <?php
  2.  
  3. abstract class Process {
  4.  
  5. protected $source;
  6. abstract function read();
  7. abstract function parse($type = "txt");
  8.  
  9. protected function __construct($source) {
  10. $this->source = $source;
  11. }
  12.  
  13. }
  14.  
  15. class File extends Process {
  16.  
  17. protected function __construct($source) {
  18. parent ::__construct($source);
  19. }
  20.  
  21. public function read() {
  22. $fileHandle = fopen($this->source, "r");
  23. while (!feof($fileHandle)) {
  24. $line = fgets($fileHandle);
  25. echo $line;
  26. }
  27. fclose($fileHandle);
  28. }
  29.  
  30. public function parse($type="txt") {
  31. switch($type) {
  32. case "txt" :
  33. // parse txt file
  34. break;
  35. case "xml" :
  36. // parse xml file
  37. break;
  38. }
  39. }
  40.  
  41. $file = new File("file.txt", "some file resource");
  42. $file->read();
Add Comment
Please, Sign In to add comment