| Conditions | 7 |
| Paths | 7 |
| Total Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 3 | public function __construct( $_path ) { |
||
| 4 | if(!is_string($_path)) |
||
| 5 | throw new JException("Path must be a string."); |
||
| 6 | if(!file_exists($_path)) |
||
| 7 | throw new JException("File [$_path] not found."); |
||
| 8 | $data = file_get_contents($_path); |
||
| 9 | $data = json_decode($data); |
||
| 10 | if($data === NULL) |
||
| 11 | throw new JException("Invalid file data. [$_path]"); |
||
| 12 | if(is_object($data)) |
||
| 13 | foreach (get_object_vars($data) as $key => $value) |
||
| 14 | $this->$key = $value; |
||
| 15 | if(is_array($data)) |
||
| 16 | $this->data = $data; |
||
| 17 | } |
||
| 18 | } |
||
| 20 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.