Version 1
[yaffs-website] / vendor / jcalderonzumba / gastonjs / src / Browser / BrowserScriptTrait.php
diff --git a/vendor/jcalderonzumba/gastonjs/src/Browser/BrowserScriptTrait.php b/vendor/jcalderonzumba/gastonjs/src/Browser/BrowserScriptTrait.php
new file mode 100644 (file)
index 0000000..769b86f
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+
+namespace Zumba\GastonJS\Browser;
+
+/**
+ * Trait BrowserScriptTrait
+ * @package Zumba\GastonJS\Browser
+ */
+trait BrowserScriptTrait {
+  /**
+   * Evaluates a script on the browser
+   * @param $script
+   * @return mixed
+   */
+  public function evaluate($script) {
+    return $this->command('evaluate', $script);
+  }
+
+  /**
+   * Executes a script on the browser
+   * @param $script
+   * @return mixed
+   */
+  public function execute($script) {
+    return $this->command('execute', $script);
+  }
+
+  /**
+   * Add desired extensions to phantomjs
+   * @param $extensions
+   * @return bool
+   */
+  public function extensions($extensions) {
+    //TODO: add error control for when extensions do not exist physically
+    foreach ($extensions as $extensionName) {
+      $this->command('add_extension', $extensionName);
+    }
+    return true;
+  }
+
+}