@@ -24,19 +24,19 @@ |
||
24 | 24 | * @licence http://www.gnu.org/licenses/gpl.txt |
25 | 25 | */ |
26 | 26 | |
27 | -require_once __DIR__ . '/../../main/inc/global.inc.php'; |
|
28 | -require_once __DIR__ . '/lib/pens.php'; |
|
29 | -require_once __DIR__ . '/chamilo_pens.php'; |
|
27 | +require_once __DIR__.'/../../main/inc/global.inc.php'; |
|
28 | +require_once __DIR__.'/lib/pens.php'; |
|
29 | +require_once __DIR__.'/chamilo_pens.php'; |
|
30 | 30 | |
31 | 31 | class ChamiloPackageHandler extends PENSPackageHandler { |
32 | 32 | public function processPackage($request, $path_to_package) { |
33 | 33 | $server = PENSServer::singleton(); |
34 | 34 | // Moves the package to archive/pens |
35 | - $path_to_archives = api_get_path(SYS_ARCHIVE_PATH) . 'pens'; |
|
36 | - if(!is_dir($path_to_archives)) { |
|
35 | + $path_to_archives = api_get_path(SYS_ARCHIVE_PATH).'pens'; |
|
36 | + if (!is_dir($path_to_archives)) { |
|
37 | 37 | mkdir($path_to_archives, 0777, true); |
38 | 38 | } |
39 | - rename($path_to_package, $path_to_archives . '/' . $request->getFilename()); |
|
39 | + rename($path_to_package, $path_to_archives.'/'.$request->getFilename()); |
|
40 | 40 | // Insert the request in the database |
41 | 41 | $chamilo_pens = new ChamiloPens($request); |
42 | 42 | $chamilo_pens->save(); |
@@ -29,19 +29,19 @@ |
||
29 | 29 | require_once __DIR__ . '/chamilo_pens.php'; |
30 | 30 | |
31 | 31 | class ChamiloPackageHandler extends PENSPackageHandler { |
32 | - public function processPackage($request, $path_to_package) { |
|
33 | - $server = PENSServer::singleton(); |
|
34 | - // Moves the package to archive/pens |
|
35 | - $path_to_archives = api_get_path(SYS_ARCHIVE_PATH) . 'pens'; |
|
36 | - if(!is_dir($path_to_archives)) { |
|
37 | - mkdir($path_to_archives, 0777, true); |
|
38 | - } |
|
39 | - rename($path_to_package, $path_to_archives . '/' . $request->getFilename()); |
|
40 | - // Insert the request in the database |
|
41 | - $chamilo_pens = new ChamiloPens($request); |
|
42 | - $chamilo_pens->save(); |
|
43 | - $server->sendAlert($request, new PENSResponse(0, 'Package successfully processed')); |
|
44 | - } |
|
32 | + public function processPackage($request, $path_to_package) { |
|
33 | + $server = PENSServer::singleton(); |
|
34 | + // Moves the package to archive/pens |
|
35 | + $path_to_archives = api_get_path(SYS_ARCHIVE_PATH) . 'pens'; |
|
36 | + if(!is_dir($path_to_archives)) { |
|
37 | + mkdir($path_to_archives, 0777, true); |
|
38 | + } |
|
39 | + rename($path_to_package, $path_to_archives . '/' . $request->getFilename()); |
|
40 | + // Insert the request in the database |
|
41 | + $chamilo_pens = new ChamiloPens($request); |
|
42 | + $chamilo_pens->save(); |
|
43 | + $server->sendAlert($request, new PENSResponse(0, 'Package successfully processed')); |
|
44 | + } |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $handler = new ChamiloPackageHandler(); |
@@ -40,9 +40,9 @@ |
||
40 | 40 | |
41 | 41 | class PENSRequestAlert extends PENSRequest { |
42 | 42 | |
43 | - public function __construct($arguments) { |
|
44 | - parent::__construct($arguments); |
|
45 | - $this->setCommand("alert"); |
|
46 | - } |
|
43 | + public function __construct($arguments) { |
|
44 | + parent::__construct($arguments); |
|
45 | + $this->setCommand("alert"); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | * @licence http://www.gnu.org/licenses/gpl.txt |
27 | 27 | */ |
28 | 28 | |
29 | -require_once __DIR__ . '/pens_request.php'; |
|
29 | +require_once __DIR__.'/pens_request.php'; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * PENSRequestReceipt |
@@ -16,15 +16,15 @@ discard block |
||
16 | 16 | * along with php-pens. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | */ |
18 | 18 | |
19 | - /** |
|
20 | - * PENSController |
|
21 | - * |
|
22 | - * Provides the PENSController class |
|
23 | - * |
|
24 | - * @package PENS |
|
25 | - * @author Guillaume Viguier-Just <[email protected]> |
|
26 | - * @licence http://www.gnu.org/licenses/gpl.txt |
|
27 | - */ |
|
19 | + /** |
|
20 | + * PENSController |
|
21 | + * |
|
22 | + * Provides the PENSController class |
|
23 | + * |
|
24 | + * @package PENS |
|
25 | + * @author Guillaume Viguier-Just <[email protected]> |
|
26 | + * @licence http://www.gnu.org/licenses/gpl.txt |
|
27 | + */ |
|
28 | 28 | |
29 | 29 | require_once(dirname(__FILE__)."/pens_request_factory.php"); |
30 | 30 | |
@@ -39,24 +39,24 @@ discard block |
||
39 | 39 | */ |
40 | 40 | abstract class PENSController { |
41 | 41 | |
42 | - /** |
|
43 | - * Parses a request based on the values present in $_REQUEST |
|
44 | - * |
|
45 | - * @return PENSRequest Request generated |
|
46 | - * @throws PENSException if the request could not be parsed |
|
47 | - */ |
|
48 | - protected function parseRequest() { |
|
49 | - $request = PENSRequestFactory::createPENSRequest($_REQUEST); |
|
50 | - return $request; |
|
51 | - } |
|
42 | + /** |
|
43 | + * Parses a request based on the values present in $_REQUEST |
|
44 | + * |
|
45 | + * @return PENSRequest Request generated |
|
46 | + * @throws PENSException if the request could not be parsed |
|
47 | + */ |
|
48 | + protected function parseRequest() { |
|
49 | + $request = PENSRequestFactory::createPENSRequest($_REQUEST); |
|
50 | + return $request; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Sends the HTTP Response to the client |
|
55 | - * |
|
56 | - * @param PENSResponse Response to be sent |
|
57 | - */ |
|
58 | - protected function sendResponse($response) { |
|
59 | - $response->send(); |
|
60 | - } |
|
53 | + /** |
|
54 | + * Sends the HTTP Response to the client |
|
55 | + * |
|
56 | + * @param PENSResponse Response to be sent |
|
57 | + */ |
|
58 | + protected function sendResponse($response) { |
|
59 | + $response->send(); |
|
60 | + } |
|
61 | 61 | |
62 | 62 | } |
@@ -16,15 +16,15 @@ discard block |
||
16 | 16 | * along with php-pens. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | */ |
18 | 18 | |
19 | - /** |
|
20 | - * PENSClient |
|
21 | - * |
|
22 | - * Provides the PENSClient class |
|
23 | - * |
|
24 | - * @package PENS |
|
25 | - * @author Guillaume Viguier-Just <[email protected]> |
|
26 | - * @licence http://www.gnu.org/licenses/gpl.txt |
|
27 | - */ |
|
19 | + /** |
|
20 | + * PENSClient |
|
21 | + * |
|
22 | + * Provides the PENSClient class |
|
23 | + * |
|
24 | + * @package PENS |
|
25 | + * @author Guillaume Viguier-Just <[email protected]> |
|
26 | + * @licence http://www.gnu.org/licenses/gpl.txt |
|
27 | + */ |
|
28 | 28 | |
29 | 29 | require_once(dirname(__FILE__)."/pens_controller.php"); |
30 | 30 | require_once(dirname(__FILE__)."/pens_request_handler.php"); |
@@ -39,75 +39,75 @@ discard block |
||
39 | 39 | * @licence http://www.gnu.org/licenses/gpl.txt |
40 | 40 | */ |
41 | 41 | class PENSClient extends PENSController { |
42 | - /** |
|
43 | - * Instance of the PENSClient |
|
44 | - * @var PENSServer |
|
45 | - */ |
|
46 | - private static $_instance; |
|
42 | + /** |
|
43 | + * Instance of the PENSClient |
|
44 | + * @var PENSServer |
|
45 | + */ |
|
46 | + private static $_instance; |
|
47 | 47 | |
48 | - /** |
|
49 | - * Request handler |
|
50 | - * @var PENSRequestHandler |
|
51 | - */ |
|
52 | - protected $_request_handler = null; |
|
48 | + /** |
|
49 | + * Request handler |
|
50 | + * @var PENSRequestHandler |
|
51 | + */ |
|
52 | + protected $_request_handler = null; |
|
53 | 53 | |
54 | - /** |
|
55 | - * Private constructor |
|
56 | - */ |
|
57 | - private function __construct() { |
|
58 | - } |
|
54 | + /** |
|
55 | + * Private constructor |
|
56 | + */ |
|
57 | + private function __construct() { |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Singleton method |
|
62 | - */ |
|
63 | - public static function singleton() { |
|
64 | - if(!isset(self::$_instance)) { |
|
65 | - $c = __CLASS__; |
|
66 | - self::$_instance = new $c; |
|
67 | - } |
|
68 | - return self::$_instance; |
|
69 | - } |
|
60 | + /** |
|
61 | + * Singleton method |
|
62 | + */ |
|
63 | + public static function singleton() { |
|
64 | + if(!isset(self::$_instance)) { |
|
65 | + $c = __CLASS__; |
|
66 | + self::$_instance = new $c; |
|
67 | + } |
|
68 | + return self::$_instance; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * Prevent users to clone the instance |
|
73 | - */ |
|
74 | - public function __clone() { |
|
75 | - trigger_error('Clone is not allowed', E_USER_ERROR); |
|
76 | - } |
|
71 | + /** |
|
72 | + * Prevent users to clone the instance |
|
73 | + */ |
|
74 | + public function __clone() { |
|
75 | + trigger_error('Clone is not allowed', E_USER_ERROR); |
|
76 | + } |
|
77 | 77 | |
78 | - public function getRequestHandler() { |
|
79 | - return $this->_request_handler; |
|
80 | - } |
|
78 | + public function getRequestHandler() { |
|
79 | + return $this->_request_handler; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Sets the request handler. Does nothing if the argument is not an instance of PENSRequestHandler |
|
84 | - * |
|
85 | - * @param PENSRequestHandler Request handler |
|
86 | - */ |
|
87 | - public function setRequestHandler($request_handler) { |
|
88 | - if($request_handler instanceof PENSRequestHandler) { |
|
89 | - $this->_request_handler = $request_handler; |
|
90 | - } |
|
91 | - } |
|
82 | + /** |
|
83 | + * Sets the request handler. Does nothing if the argument is not an instance of PENSRequestHandler |
|
84 | + * |
|
85 | + * @param PENSRequestHandler Request handler |
|
86 | + */ |
|
87 | + public function setRequestHandler($request_handler) { |
|
88 | + if($request_handler instanceof PENSRequestHandler) { |
|
89 | + $this->_request_handler = $request_handler; |
|
90 | + } |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * Receives a request, calls the handler and displays the response |
|
95 | - */ |
|
96 | - public function receiveRequest() { |
|
97 | - $request = null; |
|
98 | - try { |
|
99 | - $request = $this->parseRequest(); |
|
100 | - $command = $request->getCommand(); |
|
101 | - if($command == "alert" || $command == "receipt") { |
|
102 | - if(!is_null($this->_request_handler)) { |
|
103 | - // Call the handler |
|
104 | - $this->_request_handler->processRequest($request, new PENSResponse($_REQUEST)); |
|
105 | - } |
|
106 | - $this->sendResponse(new PENSResponse(0, $command." received and understood")); |
|
107 | - } |
|
108 | - } catch(PENSException $e) { |
|
109 | - // If we could not parse the request, send the error |
|
110 | - $this->sendResponse(new PENSResponse($e)); |
|
111 | - } |
|
112 | - } |
|
93 | + /** |
|
94 | + * Receives a request, calls the handler and displays the response |
|
95 | + */ |
|
96 | + public function receiveRequest() { |
|
97 | + $request = null; |
|
98 | + try { |
|
99 | + $request = $this->parseRequest(); |
|
100 | + $command = $request->getCommand(); |
|
101 | + if($command == "alert" || $command == "receipt") { |
|
102 | + if(!is_null($this->_request_handler)) { |
|
103 | + // Call the handler |
|
104 | + $this->_request_handler->processRequest($request, new PENSResponse($_REQUEST)); |
|
105 | + } |
|
106 | + $this->sendResponse(new PENSResponse(0, $command." received and understood")); |
|
107 | + } |
|
108 | + } catch(PENSException $e) { |
|
109 | + // If we could not parse the request, send the error |
|
110 | + $this->sendResponse(new PENSResponse($e)); |
|
111 | + } |
|
112 | + } |
|
113 | 113 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * Singleton method |
62 | 62 | */ |
63 | 63 | public static function singleton() { |
64 | - if(!isset(self::$_instance)) { |
|
64 | + if (!isset(self::$_instance)) { |
|
65 | 65 | $c = __CLASS__; |
66 | 66 | self::$_instance = new $c; |
67 | 67 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @param PENSRequestHandler Request handler |
86 | 86 | */ |
87 | 87 | public function setRequestHandler($request_handler) { |
88 | - if($request_handler instanceof PENSRequestHandler) { |
|
88 | + if ($request_handler instanceof PENSRequestHandler) { |
|
89 | 89 | $this->_request_handler = $request_handler; |
90 | 90 | } |
91 | 91 | } |
@@ -98,14 +98,14 @@ discard block |
||
98 | 98 | try { |
99 | 99 | $request = $this->parseRequest(); |
100 | 100 | $command = $request->getCommand(); |
101 | - if($command == "alert" || $command == "receipt") { |
|
102 | - if(!is_null($this->_request_handler)) { |
|
101 | + if ($command == "alert" || $command == "receipt") { |
|
102 | + if (!is_null($this->_request_handler)) { |
|
103 | 103 | // Call the handler |
104 | 104 | $this->_request_handler->processRequest($request, new PENSResponse($_REQUEST)); |
105 | 105 | } |
106 | 106 | $this->sendResponse(new PENSResponse(0, $command." received and understood")); |
107 | 107 | } |
108 | - } catch(PENSException $e) { |
|
108 | + } catch (PENSException $e) { |
|
109 | 109 | // If we could not parse the request, send the error |
110 | 110 | $this->sendResponse(new PENSResponse($e)); |
111 | 111 | } |
@@ -40,9 +40,9 @@ |
||
40 | 40 | |
41 | 41 | class PENSRequestCollect extends PENSRequest { |
42 | 42 | |
43 | - public function __construct($arguments) { |
|
44 | - parent::__construct($arguments); |
|
45 | - $this->setCommand("collect"); |
|
46 | - } |
|
43 | + public function __construct($arguments) { |
|
44 | + parent::__construct($arguments); |
|
45 | + $this->setCommand("collect"); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | * @licence http://www.gnu.org/licenses/gpl.txt |
27 | 27 | */ |
28 | 28 | |
29 | -require_once __DIR__ . '/pens_request.php'; |
|
29 | +require_once __DIR__.'/pens_request.php'; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * PENSRequestReceipt |
@@ -16,15 +16,15 @@ discard block |
||
16 | 16 | * along with php-pens. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | */ |
18 | 18 | |
19 | - /** |
|
20 | - * PENSPackageHandler |
|
21 | - * |
|
22 | - * Provides the PENSPackageHandler abstract class |
|
23 | - * |
|
24 | - * @package PENS |
|
25 | - * @author Guillaume Viguier-Just <[email protected]> |
|
26 | - * @licence http://www.gnu.org/licenses/gpl.txt |
|
27 | - */ |
|
19 | + /** |
|
20 | + * PENSPackageHandler |
|
21 | + * |
|
22 | + * Provides the PENSPackageHandler abstract class |
|
23 | + * |
|
24 | + * @package PENS |
|
25 | + * @author Guillaume Viguier-Just <[email protected]> |
|
26 | + * @licence http://www.gnu.org/licenses/gpl.txt |
|
27 | + */ |
|
28 | 28 | |
29 | 29 | require_once(dirname(__FILE__)."/pens_config.php"); |
30 | 30 | |
@@ -39,76 +39,76 @@ discard block |
||
39 | 39 | * @licence http://www.gnu.org/licenses/gpl.txt |
40 | 40 | */ |
41 | 41 | abstract class PENSPackageHandler { |
42 | - /** |
|
43 | - * Array of supported package types for this handler. Set by default to PENSConfig::$allowed_package_types |
|
44 | - * @var array |
|
45 | - */ |
|
46 | - protected $_supported_package_types = null; |
|
42 | + /** |
|
43 | + * Array of supported package types for this handler. Set by default to PENSConfig::$allowed_package_types |
|
44 | + * @var array |
|
45 | + */ |
|
46 | + protected $_supported_package_types = null; |
|
47 | 47 | |
48 | - /** |
|
49 | - * Array of supported package formats for this handler. Set by default to PENSConfig::$allowed_package_formats |
|
50 | - * @var array |
|
51 | - */ |
|
52 | - protected $_supported_package_formats = null; |
|
48 | + /** |
|
49 | + * Array of supported package formats for this handler. Set by default to PENSConfig::$allowed_package_formats |
|
50 | + * @var array |
|
51 | + */ |
|
52 | + protected $_supported_package_formats = null; |
|
53 | 53 | |
54 | - /** |
|
55 | - * Constructor. Sets the default values of supported_package_types and supported_package_formats |
|
56 | - */ |
|
57 | - public function __construct() { |
|
58 | - $this->_supported_package_types = PENSConfig::$allowed_package_types; |
|
59 | - $this->_supported_package_formats = PENSConfig::$allowed_package_formats; |
|
60 | - } |
|
54 | + /** |
|
55 | + * Constructor. Sets the default values of supported_package_types and supported_package_formats |
|
56 | + */ |
|
57 | + public function __construct() { |
|
58 | + $this->_supported_package_types = PENSConfig::$allowed_package_types; |
|
59 | + $this->_supported_package_formats = PENSConfig::$allowed_package_formats; |
|
60 | + } |
|
61 | 61 | |
62 | - public function getSupportedPackageTypes() { |
|
63 | - return $this->_supported_package_types; |
|
64 | - } |
|
62 | + public function getSupportedPackageTypes() { |
|
63 | + return $this->_supported_package_types; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * Sets the supported package types. All package types in the array provided as an argument |
|
68 | - * not present in PENSConfig::$allowed_package_types will be ignored. The supported_package_types |
|
69 | - * will be set to null if the argument given is not an array |
|
70 | - * |
|
71 | - * @param array Supported package types |
|
72 | - */ |
|
73 | - public function setSupportedPackageTypes($supported_package_types) { |
|
74 | - $this->_supported_package_types = null; |
|
75 | - if(is_array($supported_package_types)) { |
|
76 | - foreach($supported_package_types as $package_type) { |
|
77 | - if(in_array($package_type, PENSConfig::$allowed_package_types)) { |
|
78 | - $this->_supported_package_types[] = $package_type; |
|
79 | - } |
|
80 | - } |
|
81 | - } |
|
82 | - } |
|
66 | + /** |
|
67 | + * Sets the supported package types. All package types in the array provided as an argument |
|
68 | + * not present in PENSConfig::$allowed_package_types will be ignored. The supported_package_types |
|
69 | + * will be set to null if the argument given is not an array |
|
70 | + * |
|
71 | + * @param array Supported package types |
|
72 | + */ |
|
73 | + public function setSupportedPackageTypes($supported_package_types) { |
|
74 | + $this->_supported_package_types = null; |
|
75 | + if(is_array($supported_package_types)) { |
|
76 | + foreach($supported_package_types as $package_type) { |
|
77 | + if(in_array($package_type, PENSConfig::$allowed_package_types)) { |
|
78 | + $this->_supported_package_types[] = $package_type; |
|
79 | + } |
|
80 | + } |
|
81 | + } |
|
82 | + } |
|
83 | 83 | |
84 | - public function getSupportedPackageFormats() { |
|
85 | - return $this->_supported_package_formats; |
|
86 | - } |
|
84 | + public function getSupportedPackageFormats() { |
|
85 | + return $this->_supported_package_formats; |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * Sets the supported package formats. All package types in the array provided as an argument |
|
90 | - * not present in PENSConfig::$allowed_package_formats will be ignored. The supported_package_formats |
|
91 | - * will be set to null if the argument given is not an array. |
|
92 | - * |
|
93 | - * @param array Supported package formats |
|
94 | - */ |
|
95 | - public function setSupportedPackageFormats($supported_package_formats) { |
|
96 | - $this->_supported_package_formats = null; |
|
97 | - if(is_array($supported_package_formats)) { |
|
98 | - foreach($supported_package_formats as $package_format) { |
|
99 | - if(in_array($package_format, PENSConfig::$allowed_package_formats)) { |
|
100 | - $this->_supported_package_formats[] = $package_format; |
|
101 | - } |
|
102 | - } |
|
103 | - } |
|
104 | - } |
|
88 | + /** |
|
89 | + * Sets the supported package formats. All package types in the array provided as an argument |
|
90 | + * not present in PENSConfig::$allowed_package_formats will be ignored. The supported_package_formats |
|
91 | + * will be set to null if the argument given is not an array. |
|
92 | + * |
|
93 | + * @param array Supported package formats |
|
94 | + */ |
|
95 | + public function setSupportedPackageFormats($supported_package_formats) { |
|
96 | + $this->_supported_package_formats = null; |
|
97 | + if(is_array($supported_package_formats)) { |
|
98 | + foreach($supported_package_formats as $package_format) { |
|
99 | + if(in_array($package_format, PENSConfig::$allowed_package_formats)) { |
|
100 | + $this->_supported_package_formats[] = $package_format; |
|
101 | + } |
|
102 | + } |
|
103 | + } |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * Processes the package. Must be implemented by subclasses |
|
108 | - * |
|
109 | - * @param PENSRequestCollect Collect request sent by the client |
|
110 | - * @param string Path to the collected package on the hard drive |
|
111 | - */ |
|
112 | - abstract public function processPackage($request, $path_to_package); |
|
106 | + /** |
|
107 | + * Processes the package. Must be implemented by subclasses |
|
108 | + * |
|
109 | + * @param PENSRequestCollect Collect request sent by the client |
|
110 | + * @param string Path to the collected package on the hard drive |
|
111 | + */ |
|
112 | + abstract public function processPackage($request, $path_to_package); |
|
113 | 113 | |
114 | 114 | } |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function setSupportedPackageTypes($supported_package_types) { |
74 | 74 | $this->_supported_package_types = null; |
75 | - if(is_array($supported_package_types)) { |
|
76 | - foreach($supported_package_types as $package_type) { |
|
77 | - if(in_array($package_type, PENSConfig::$allowed_package_types)) { |
|
75 | + if (is_array($supported_package_types)) { |
|
76 | + foreach ($supported_package_types as $package_type) { |
|
77 | + if (in_array($package_type, PENSConfig::$allowed_package_types)) { |
|
78 | 78 | $this->_supported_package_types[] = $package_type; |
79 | 79 | } |
80 | 80 | } |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function setSupportedPackageFormats($supported_package_formats) { |
96 | 96 | $this->_supported_package_formats = null; |
97 | - if(is_array($supported_package_formats)) { |
|
98 | - foreach($supported_package_formats as $package_format) { |
|
99 | - if(in_array($package_format, PENSConfig::$allowed_package_formats)) { |
|
97 | + if (is_array($supported_package_formats)) { |
|
98 | + foreach ($supported_package_formats as $package_format) { |
|
99 | + if (in_array($package_format, PENSConfig::$allowed_package_formats)) { |
|
100 | 100 | $this->_supported_package_formats[] = $package_format; |
101 | 101 | } |
102 | 102 | } |
@@ -16,15 +16,15 @@ discard block |
||
16 | 16 | * along with php-pens. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | */ |
18 | 18 | |
19 | - /** |
|
20 | - * PENSRequestHandler |
|
21 | - * |
|
22 | - * Provides the PENSRequestHandler abstract class |
|
23 | - * |
|
24 | - * @package PENS |
|
25 | - * @author Guillaume Viguier-Just <[email protected]> |
|
26 | - * @licence http://www.gnu.org/licenses/gpl.txt |
|
27 | - */ |
|
19 | + /** |
|
20 | + * PENSRequestHandler |
|
21 | + * |
|
22 | + * Provides the PENSRequestHandler abstract class |
|
23 | + * |
|
24 | + * @package PENS |
|
25 | + * @author Guillaume Viguier-Just <[email protected]> |
|
26 | + * @licence http://www.gnu.org/licenses/gpl.txt |
|
27 | + */ |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * PENSRequestHandler |
@@ -37,12 +37,12 @@ discard block |
||
37 | 37 | * @licence http://www.gnu.org/licenses/gpl.txt |
38 | 38 | */ |
39 | 39 | abstract class PENSRequestHandler { |
40 | - /** |
|
41 | - * Processes the request. Must be implemented by subclasses |
|
42 | - * |
|
43 | - * @param PENSRequest Alert or Receipt request sent by the server |
|
44 | - * @param PENSResponse Response sent by the server (error, error-text etc...) |
|
45 | - */ |
|
46 | - abstract public function processRequest($request, $response); |
|
40 | + /** |
|
41 | + * Processes the request. Must be implemented by subclasses |
|
42 | + * |
|
43 | + * @param PENSRequest Alert or Receipt request sent by the server |
|
44 | + * @param PENSResponse Response sent by the server (error, error-text etc...) |
|
45 | + */ |
|
46 | + abstract public function processRequest($request, $response); |
|
47 | 47 | } |
48 | 48 |
@@ -40,9 +40,9 @@ |
||
40 | 40 | |
41 | 41 | class PENSRequestReceipt extends PENSRequest { |
42 | 42 | |
43 | - public function __construct($arguments) { |
|
44 | - parent::__construct($arguments); |
|
45 | - $this->setCommand("receipt"); |
|
46 | - } |
|
43 | + public function __construct($arguments) { |
|
44 | + parent::__construct($arguments); |
|
45 | + $this->setCommand("receipt"); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | * @licence http://www.gnu.org/licenses/gpl.txt |
27 | 27 | */ |
28 | 28 | |
29 | -require_once __DIR__ . '/pens_request.php'; |
|
29 | +require_once __DIR__.'/pens_request.php'; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * PENSRequestReceipt |
@@ -43,26 +43,26 @@ |
||
43 | 43 | */ |
44 | 44 | class PENSRequestFactory { |
45 | 45 | |
46 | - /** |
|
47 | - * Factory method |
|
48 | - * |
|
49 | - * Creates the right PENSRequest object, based on the command inside the arguments |
|
50 | - * |
|
51 | - * @param array Associative array of arguments |
|
52 | - * @return mixed PENSRequestAlert or PENSRequestCollect or PENSRequestReceipt |
|
53 | - * |
|
54 | - * @throws PENSException with code 2002 if command is invalid |
|
55 | - */ |
|
56 | - public static function createPENSRequest($arguments) { |
|
57 | - $command = $arguments["command"]; |
|
58 | - if($command == "alert") { |
|
59 | - return new PENSRequestAlert($arguments); |
|
60 | - } else if($command == "collect") { |
|
61 | - return new PENSRequestCollect($arguments); |
|
62 | - } else if($command == "receipt") { |
|
63 | - return new PENSRequestReceipt($arguments); |
|
64 | - } else { |
|
65 | - throw new PENSException(2002); |
|
66 | - } |
|
67 | - } |
|
46 | + /** |
|
47 | + * Factory method |
|
48 | + * |
|
49 | + * Creates the right PENSRequest object, based on the command inside the arguments |
|
50 | + * |
|
51 | + * @param array Associative array of arguments |
|
52 | + * @return mixed PENSRequestAlert or PENSRequestCollect or PENSRequestReceipt |
|
53 | + * |
|
54 | + * @throws PENSException with code 2002 if command is invalid |
|
55 | + */ |
|
56 | + public static function createPENSRequest($arguments) { |
|
57 | + $command = $arguments["command"]; |
|
58 | + if($command == "alert") { |
|
59 | + return new PENSRequestAlert($arguments); |
|
60 | + } else if($command == "collect") { |
|
61 | + return new PENSRequestCollect($arguments); |
|
62 | + } else if($command == "receipt") { |
|
63 | + return new PENSRequestReceipt($arguments); |
|
64 | + } else { |
|
65 | + throw new PENSException(2002); |
|
66 | + } |
|
67 | + } |
|
68 | 68 | } |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | * @licence http://www.gnu.org/licenses/gpl.txt |
28 | 28 | */ |
29 | 29 | |
30 | -require_once __DIR__ . '/pens_exception.php'; |
|
31 | -require_once __DIR__ . '/pens_request_receipt.php'; |
|
32 | -require_once __DIR__ . '/pens_request_collect.php'; |
|
33 | -require_once __DIR__ . '/pens_request_alert.php'; |
|
30 | +require_once __DIR__.'/pens_exception.php'; |
|
31 | +require_once __DIR__.'/pens_request_receipt.php'; |
|
32 | +require_once __DIR__.'/pens_request_collect.php'; |
|
33 | +require_once __DIR__.'/pens_request_alert.php'; |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * PENSRequestFactory |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public static function createPENSRequest($arguments) { |
57 | 57 | $command = $arguments["command"]; |
58 | - if($command == "alert") { |
|
58 | + if ($command == "alert") { |
|
59 | 59 | return new PENSRequestAlert($arguments); |
60 | - } else if($command == "collect") { |
|
60 | + } else if ($command == "collect") { |
|
61 | 61 | return new PENSRequestCollect($arguments); |
62 | - } else if($command == "receipt") { |
|
62 | + } else if ($command == "receipt") { |
|
63 | 63 | return new PENSRequestReceipt($arguments); |
64 | 64 | } else { |
65 | 65 | throw new PENSException(2002); |