KamranAhmed\Smasher\Path::createItem PHP Method

createItem() public method

Creates the path based upon the type of it
public createItem ( array $detail = [] )
$detail array
    public function createItem($detail = [])
    {
        // Default options
        $defaults = ['@type' => 'dir'];
        $detail = array_merge($defaults, $detail);
        $old = umask(0);
        $type = $detail['@type'];
        if ($type === 'dir' && !file_exists($this->path)) {
            mkdir($this->path, 0777, true);
        } elseif ($type === 'file') {
            $content = $detail['@content'];
            $handle = fopen($this->path, "wb");
            fwrite($handle, $content);
            fclose($handle);
        } elseif ($type === 'link') {
            $target = $detail['@destination'];
            $link = $this->path;
            symlink($target, $link);
        }
        umask($old);
    }