File tree Expand file tree Collapse file tree 3 files changed +10
-4
lines changed Expand file tree Collapse file tree 3 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ abstract class Archive
1515 *
1616 * @param int $level Compression level (0 to 9)
1717 * @param int $type Type of compression to use (use COMPRESS_* constants)
18- * @return mixed
18+ * @throws ArchiveIllegalCompressionException
1919 */
2020 abstract public function setCompression ($ level = 9 , $ type = Archive::COMPRESS_AUTO );
2121
Original file line number Diff line number Diff line change @@ -28,12 +28,15 @@ class Tar extends Archive
2828 * Sets the compression to use
2929 *
3030 * @param int $level Compression level (0 to 9)
31- * @param int $type Type of compression to use (use COMPRESS_* constants)
32- * @return mixed
31+ * @param int $type Type of compression to use (use COMPRESS_* constants)
32+ * @throws ArchiveIllegalCompressionException
3333 */
3434 public function setCompression ($ level = 9 , $ type = Archive::COMPRESS_AUTO )
3535 {
3636 $ this ->compressioncheck ($ type );
37+ if ($ level < -1 || $ level > 9 ) {
38+ throw new ArchiveIllegalCompressionException ('Compression level should be between -1 and 9 ' );
39+ }
3740 $ this ->comptype = $ type ;
3841 $ this ->complevel = $ level ;
3942 if ($ level == 0 ) $ this ->comptype = Archive::COMPRESS_NONE ;
Original file line number Diff line number Diff line change @@ -34,10 +34,13 @@ class Zip extends Archive
3434 *
3535 * @param int $level Compression level (0 to 9)
3636 * @param int $type Type of compression to use ignored for ZIP
37- * @return mixed
37+ * @throws ArchiveIllegalCompressionException
3838 */
3939 public function setCompression ($ level = 9 , $ type = Archive::COMPRESS_AUTO )
4040 {
41+ if ($ level < -1 || $ level > 9 ) {
42+ throw new ArchiveIllegalCompressionException ('Compression level should be between -1 and 9 ' );
43+ }
4144 $ this ->complevel = $ level ;
4245 }
4346
You can’t perform that action at this time.
0 commit comments