reorder code and files, remove the filtered source dir implementation
[pharext/pharext] / src / pharext / Openssl / PrivateKey.php
index 1d3aed1e6d3d2a035ce2a7e1933e0d1590a88f7d..470983da3972ccf8c21634c7602a7a3e9a000730 100644 (file)
@@ -4,19 +4,38 @@ namespace pharext\Openssl;
 
 class PrivateKey
 {
+       /**
+        * OpenSSL pkey resource
+        * @var resource
+        */
        private $key;
-       
+
+       /**
+        * Read a private key
+        * @param string $file
+        * @param string $password
+        * @throws \Exception
+        */
        function __construct($file, $password) {
                $this->key = openssl_pkey_get_private("file://$file", $password);
                if (!is_resource($this->key)) {
                        throw new \Exception("Could not load private key");
                }
        }
-       
+
+       /**
+        * Sign the PHAR
+        * @param \Phar $package
+        */
        function sign(\Phar $package) {
                $package->setSignatureAlgorithm(\Phar::OPENSSL, $this->key);
        }
-       
+
+       /**
+        * Export the public key to a file
+        * @param string $file
+        * @throws \Exception
+        */
        function exportPublicKey($file) {
                if (!file_put_contents("$file.tmp", openssl_pkey_get_details($this->key)["key"])
                ||      !rename("$file.tmp", $file)