File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,6 +29,11 @@ public function sign()
2929 return $ this ->service ->sign ($ this ->param );
3030 }
3131
32+ public function getVersion ()
33+ {
34+ return $ this ->service ->getVersion ($ this ->param );
35+ }
36+
3237 public function setParam (JSignParam $ param )
3338 {
3439 $ this ->param = $ param ;
Original file line number Diff line number Diff line change @@ -51,6 +51,20 @@ public function sign(JSignParam $params)
5151 }
5252 }
5353
54+ public function getVersion (JSignParam $ params )
55+ {
56+ $ java = $ this ->javaCommand ($ params );
57+ $ jSignPdf = $ params ->getjSignPdfJarPath ();
58+ if (!$ jSignPdf && class_exists ('JSignPDF\JSignPDFBin\JSignPdfPathService ' )) {
59+ $ jSignPdf = \JSignPDF \JSignPDFBin \JSignPdfPathService::jSignPdfJarPath ();
60+ }
61+ $ this ->throwIf (!file_exists ($ jSignPdf ), 'Jar of JSignPDF not found on path: ' . $ jSignPdf );
62+
63+ $ command = "$ java -jar $ jSignPdf --version " ;
64+ \exec ($ command , $ output );
65+ return explode ('version ' , $ output [0 ])[1 ];
66+ }
67+
5468 private function validation (JSignParam $ params )
5569 {
5670 $ this ->throwIf (empty ($ params ->getTempPath ()) || !is_writable ($ params ->getTempPath ()), 'Temp Path is invalid or has not permission to writable. ' );
Original file line number Diff line number Diff line change @@ -100,4 +100,11 @@ public function testSignWhenJavaNotFound()
100100 $ params = JSignParamBuilder::instance ()->withDefault ()->setIsUseJavaInstalled (true );
101101 $ this ->service ->sign ($ params );
102102 }
103+
104+ public function testGetVersion ()
105+ {
106+ $ params = JSignParamBuilder::instance ()->withDefault ();
107+ $ version = $ this ->service ->getVersion ($ params );
108+ $ this ->assertNotEmpty ($ version );
109+ }
103110}
You can’t perform that action at this time.
0 commit comments