# Hooks

class Hooks

## Methods

`public static` | `` | `exists($filename)` | No description |
`public static` | `` | `copy($filename, $dist)` | No description |
`public static` | `` | `delete($filename)` | No description |
`public static` | `` | `append($filename, $code)` | No description |
`public static` | `` | `write($filename, $code)` | No description |
`public static` | `` | `replace($filename, $replaces = [])` | No description |
`public static` | `` | `read($filename)` | No description |
`public static` | `` | `toJson($filename)` | No description |
`public static` | `` | `unJson($filename)` | No description |
`public static` | `` | `create($filename, $source = '')` | No description |
`public static` | `` | `folder($foldername)` | No description |
`public static` | `` | `__callStatic($name, $arguments)` | No description |

## Details

at line 7

### `exists()`

`public static exists($filename)`

#### Parameters

| `$filename` |

at line 11

### `copy()`

`public static copy($filename, $dist)`

#### Parameters

| `$filename` |
| `$dist` |

at line 15

### `delete()`

`public static delete($filename)`

#### Parameters

| `$filename` |

at line 21

### `append()`

`public static append($filename, $code)`

#### Parameters

| `$filename` |
| `$code` |

at line 27

### `write()`

`public static write($filename, $code)`

#### Parameters

| `$filename` |
| `$code` |

at line 33

### `replace()`

`public static replace($filename, $replaces = [])`

#### Parameters

| `$filename` |
| `$replaces` |

at line 43

### `read()`

`public static read($filename)`

#### Parameters

| `$filename` |

at line 49

### `toJson()`

`public static toJson($filename)`

#### Parameters

| `$filename` |

at line 55

### `unJson()`

`public static unJson($filename)`

#### Parameters

| `$filename` |

at line 61

### `create()`

`public static create($filename, $source = '')`

#### Parameters

| `$filename` |
| `$source` |

at line 67

### `folder()`

`public static folder($foldername)`

#### Parameters

| `$foldername` |

at line 73

### `__callStatic()`

`public static __callStatic($name, $arguments)`

#### Parameters

| `$name` |
| `$arguments` |

## Source code

    <?php

    	namespace App\Khan\Component\Hooks;

    	class Hooks {

    	    public static function exists($filename){
    	        return file_exists($filename);
    	    }

    	    public static function copy($filename, $dist){
    	        return @copy($filename, $dist);
    	    }

    	    public static function delete($filename){
    	        if(Hooks::exists($filename)){
    	            return @unlink($filename);
    	        }
    	    }

    	    public static function append($filename, $code){
    	        if(Hooks::exists($filename)){
    	            return file_put_contents($filename, $code, FILE_APPEND);
    	        }
    	    }

    	    public static function write($filename, $code){
    	        if(Hooks::exists($filename)){
    	            return file_put_contents($filename, $code);
    	        }
    	    }

    	    public static function replace($filename, $replaces = []){
    	        if(Hooks::exists($filename)){
    	            $resources = file_get_contents($filename);
    	            foreach ($replaces as $key => $value) {
    	                $resources = str_replace($key, $value, $resources);
    	            }
    	            return $resources;
    	        }
    	    }

    	    public static function read($filename){
    	        if(Hooks::exists($filename)){
    	            return file_get_contents($filename);
    	        }
    	    }

    	    public static function toJson($filename){
    	        if(Hooks::exists($filename)){
    	            return json_encode(file_get_contents($filename), JSON_PRETTY_PRINT);
    	        }
    	    }

    	    public static function unJson($filename){
    	        if(Hooks::exists($filename)){
    	            return json_decode(file_get_contents($filename));
    	        }
    	    }

    	    public static function create($filename, $source = ''){
    	        if(!Hooks::exists($filename)){
    	            return file_put_contents($filename, $source);
    	        }
    	    }

    	    public static function folder($foldername){
    	        if(!Hooks::exists($foldername)){
    	            return @mkdir($foldername);
    	        }
    	    }

    	    public static function __callStatic($name, $arguments)
    	    {
    	        return call_user_func_array([$this, $name], $arguments);
    	    }

    	}