Просмотр исходного кода

Adding timeout param to client

Jonny Wenmoth 12 лет назад
Родитель
Сommit
da80a3e876
2 измененных файлов с 15 добавлено и 2 удалено
  1. 6 0
      composer.json
  2. 9 2
      src/JonnyW/PhantomJs/Client.php

+ 6 - 0
composer.json

@@ -15,11 +15,17 @@
     "require": {
     	"php": ">=5.3.0"
     },
+    "require-dev": {
+        "phpunit/phpunit": "3.7.*"
+    },
     "autoload": {
         "psr-0": {
             "JonnyW\\PhantomJs\\": "src"
         },
 		"classmap": ["src/"]
+    },
+    "config": {
+        "bin-dir": "bin"
     },
 	"bin": [
         "bin/phantomjs"

+ 9 - 2
src/JonnyW/PhantomJs/Client.php

@@ -44,6 +44,13 @@ class Client implements ClientInterface
 	 * @var string
 	 */
 	protected $phantomJS;
+	
+	/**
+	 * Request timeout period
+	 *
+	 * @var int
+	 */
+	protected $timeout;
 
 	/**
 	 * Internal constructor
@@ -247,12 +254,12 @@ class Client implements ClientInterface
 	/**
 	 * Remove temporary script file
 	 *
-	 * @param string $file
+	 * @param string|boolean $file
 	 * @return JonnyW\PhantomJs\ClientInterface
 	 */
 	protected function removeScript($file)
 	{
-		if($file && file_exists($file)) {
+		if(is_string($file) && file_exists($file)) {
 			unlink($file);
 		}