Conditions | 20 |
Paths | 20 |
Total Lines | 65 |
Code Lines | 44 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
61 | public function queryFromFile($sql_file_path) |
||
62 | { |
||
63 | $tables = array(); |
||
64 | |||
65 | if (!file_exists($sql_file_path)) { |
||
66 | return false; |
||
67 | } |
||
68 | $sql_query = trim(fread(fopen($sql_file_path, 'r'), filesize($sql_file_path))); |
||
69 | SqlUtility::splitMySqlFile($pieces, $sql_query); |
||
70 | $this->db->connect(); |
||
71 | foreach ($pieces as $piece) { |
||
72 | $piece = trim($piece); |
||
73 | // [0] contains the prefixed query |
||
74 | // [4] contains unprefixed table name |
||
75 | $prefixed_query = SqlUtility::prefixQuery($piece, $this->db->prefix()); |
||
76 | if ($prefixed_query != false) { |
||
77 | $table = $this->db->prefix($prefixed_query[4]); |
||
78 | if ($prefixed_query[1] == 'CREATE TABLE') { |
||
79 | if ($this->db->query($prefixed_query[0]) != false) { |
||
80 | if (!isset($this->s_tables['create'][$table])) { |
||
81 | $this->s_tables['create'][$table] = 1; |
||
82 | } |
||
83 | } else { |
||
84 | if (!isset($this->f_tables['create'][$table])) { |
||
85 | $this->f_tables['create'][$table] = 1; |
||
86 | } |
||
87 | } |
||
88 | } elseif ($prefixed_query[1] == 'INSERT INTO') { |
||
89 | if ($this->db->query($prefixed_query[0]) != false) { |
||
90 | if (!isset($this->s_tables['insert'][$table])) { |
||
91 | $this->s_tables['insert'][$table] = 1; |
||
92 | } else { |
||
93 | $this->s_tables['insert'][$table]++; |
||
94 | } |
||
95 | } else { |
||
96 | if (!isset($this->f_tables['insert'][$table])) { |
||
97 | $this->f_tables['insert'][$table] = 1; |
||
98 | } else { |
||
99 | $this->f_tables['insert'][$table]++; |
||
100 | } |
||
101 | } |
||
102 | } elseif ($prefixed_query[1] == 'ALTER TABLE') { |
||
103 | if ($this->db->query($prefixed_query[0]) != false) { |
||
104 | if (!isset($this->s_tables['alter'][$table])) { |
||
105 | $this->s_tables['alter'][$table] = 1; |
||
106 | } |
||
107 | } else { |
||
108 | if (!isset($this->s_tables['alter'][$table])) { |
||
109 | $this->f_tables['alter'][$table] = 1; |
||
110 | } |
||
111 | } |
||
112 | } elseif ($prefixed_query[1] == 'DROP TABLE') { |
||
113 | if ($this->db->query('DROP TABLE '.$table) != false) { |
||
114 | if (!isset($this->s_tables['drop'][$table])) { |
||
115 | $this->s_tables['drop'][$table] = 1; |
||
116 | } |
||
117 | } else { |
||
118 | if (!isset($this->s_tables['drop'][$table])) { |
||
119 | $this->f_tables['drop'][$table] = 1; |
||
120 | } |
||
121 | } |
||
122 | } |
||
123 | } |
||
124 | } |
||
125 | return true; |
||
126 | } |
||
237 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.