Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
File.php
Go to the documentation of this file.
1 <?php
7 
13 class File extends \SplFileObject
14 {
20  protected $_currentStatement = '';
21 
27  public function current()
28  {
30  }
31 
37  public function next()
38  {
39  $this->_currentStatement = '';
40  while (!$this->eof()) {
41  $line = $this->fgets();
42  if (strlen(trim($line))) {
43  $this->_currentStatement .= $line;
44  if ($this->_isLineLastInCommand($line)) {
45  break;
46  }
47  }
48  }
49  }
50 
56  public function rewind()
57  {
58  parent::rewind();
59  $this->next();
60  }
61 
68  protected function _isComment($line)
69  {
70  return $line[0] == '#' || substr($line, 0, 2) == '--';
71  }
72 
79  protected function _isLineLastInCommand($line)
80  {
81  $cleanLine = trim($line);
82  $lineLength = strlen($cleanLine);
83 
84  $returnResult = false;
85  if ($lineLength > 0) {
86  $lastSymbolIndex = $lineLength - 1;
87  if ($cleanLine[$lastSymbolIndex] == ';') {
88  $returnResult = true;
89  }
90  }
91 
92  return $returnResult;
93  }
94 }