1
1
<?php
2
- /**
2
+
3
+ /*
3
4
* This file is part of the brainbits transcoder package.
4
5
*
5
- * (c) 2012-2013 brainbits GmbH (http://www.brainbits.net)
6
+ * (c) brainbits GmbH
6
7
*
7
8
* For the full copyright and license information, please view the LICENSE
8
9
* file that was distributed with this source code.
9
10
*/
10
11
11
12
namespace Brainbits \Transcoder \Decoder ;
12
13
14
+ use Brainbits \Transcoder \Exception \DecodeFailedException ;
15
+ use Symfony \Component \Process \Process ;
13
16
use Symfony \Component \Process \ProcessBuilder ;
14
17
15
18
/**
@@ -39,18 +42,6 @@ public function __construct($executable = '7z')
39
42
$ this ->executable = $ executable ;
40
43
}
41
44
42
- /**
43
- * @return \Symfony\Component\Process\Process
44
- */
45
- public function getProcess ()
46
- {
47
- $ processBuilder = new ProcessBuilder (
48
- [$ this ->executable , 'e ' , '-si ' , '-so ' , '-an ' , '-txz ' , '-m0=lzma2 ' , '-mx=9 ' , '-mfb=64 ' , '-md=32m ' ]
49
- );
50
- $ processBuilder ->setInput ($ this ->data );
51
- return $ processBuilder ->getProcess ();
52
- }
53
-
54
45
/**
55
46
* Return executable
56
47
*
@@ -74,7 +65,7 @@ public function decode($data)
74
65
if ($ process ->isSuccessful ()) {
75
66
$ data = $ process ->getOutput ();
76
67
} else {
77
- throw new \ Exception ('7z failure: ' .$ process ->getOutput ().$ process ->getErrorOutput ());
68
+ throw new DecodeFailedException ('7z failure: ' .$ process ->getOutput ().$ process ->getErrorOutput ());
78
69
}
79
70
80
71
return $ data ;
@@ -87,4 +78,16 @@ public function supports($type)
87
78
{
88
79
return self ::TYPE === $ type ;
89
80
}
81
+
82
+ /**
83
+ * @return Process
84
+ */
85
+ private function getProcess ()
86
+ {
87
+ $ processBuilder = new ProcessBuilder (
88
+ [$ this ->executable , 'e ' , '-si ' , '-so ' , '-an ' , '-txz ' , '-m0=lzma2 ' , '-mx=9 ' , '-mfb=64 ' , '-md=32m ' ]
89
+ );
90
+ $ processBuilder ->setInput ($ this ->data );
91
+ return $ processBuilder ->getProcess ();
92
+ }
90
93
}
0 commit comments