Code Duplication    Length = 37-37 lines in 2 locations

src/Ifsnop/Mysqldump/Mysqldump.php 2 locations

@@ 1082-1118 (lines=37) @@
1079
    }
1080
}
1081
1082
class CompressBzip2 extends CompressManagerFactory
1083
{
1084
    private $fileHandler = null;
1085
1086
    public function __construct()
1087
    {
1088
        if (! function_exists("bzopen")) {
1089
            throw new Exception("Compression is enabled, but bzip2 lib is not installed or configured properly");
1090
        }
1091
    }
1092
1093
    /**
1094
     * @param string $filename
1095
     */
1096
    public function open($filename)
1097
    {
1098
        $this->fileHandler = bzopen($filename, "w");
1099
        if (false === $this->fileHandler) {
1100
            throw new Exception("Output file is not writable");
1101
        }
1102
1103
        return true;
1104
    }
1105
1106
    public function write($str)
1107
    {
1108
        if (false === ($bytesWritten = bzwrite($this->fileHandler, $str))) {
1109
            throw new Exception("Writting to file failed! Probably, there is no more free space left?");
1110
        }
1111
        return $bytesWritten;
1112
    }
1113
1114
    public function close()
1115
    {
1116
        return bzclose($this->fileHandler);
1117
    }
1118
}
1119
1120
class CompressGzip extends CompressManagerFactory
1121
{
@@ 1120-1156 (lines=37) @@
1117
    }
1118
}
1119
1120
class CompressGzip extends CompressManagerFactory
1121
{
1122
    private $fileHandler = null;
1123
1124
    public function __construct()
1125
    {
1126
        if (! function_exists("gzopen")) {
1127
            throw new Exception("Compression is enabled, but gzip lib is not installed or configured properly");
1128
        }
1129
    }
1130
1131
    /**
1132
     * @param string $filename
1133
     */
1134
    public function open($filename)
1135
    {
1136
        $this->fileHandler = gzopen($filename, "wb");
1137
        if (false === $this->fileHandler) {
1138
            throw new Exception("Output file is not writable");
1139
        }
1140
1141
        return true;
1142
    }
1143
1144
    public function write($str)
1145
    {
1146
        if (false === ($bytesWritten = gzwrite($this->fileHandler, $str))) {
1147
            throw new Exception("Writting to file failed! Probably, there is no more free space left?");
1148
        }
1149
        return $bytesWritten;
1150
    }
1151
1152
    public function close()
1153
    {
1154
        return gzclose($this->fileHandler);
1155
    }
1156
}
1157
1158
class CompressNone extends CompressManagerFactory
1159
{