Skip to content

Commit

Permalink
Merge pull request #1 from utopia-php/remove-exceptions
Browse files Browse the repository at this point in the history
Remove exception throwing from Curl
  • Loading branch information
eldadfux authored Mar 23, 2021
2 parents c2ab9fa + 85d3d85 commit adfc2d0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Analytics/Analytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

abstract class Analytics
{
protected bool $enabled = true;
protected $enabled = true;

/**
* Enables tracking for this instance.
Expand Down
11 changes: 2 additions & 9 deletions src/Analytics/GoogleAnalytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ public function __construct(string $tid, string $cid)
* Specifies the event value. Values must be non-negative.
*
* @return bool
*
* @throws Exception
*/
public function createEvent(string $category, string $action, string $label = null, int $value = null): bool
{
Expand Down Expand Up @@ -89,8 +87,6 @@ public function createEvent(string $category, string $action, string $label = nu
* The title of the page / document.
*
* @return bool
*
* @throws Exception
*/
public function createPageView(string $hostname, string $page, string $title = null): bool
{
Expand All @@ -116,11 +112,6 @@ private function execute(array $query): void
$this->prepareCurl($ch, $query);

curl_exec($ch);

if (curl_errno($ch)) {
throw new Exception('Error:' . curl_error($ch));
}

curl_close($ch);
}

Expand All @@ -129,6 +120,8 @@ private function prepareCurl(&$ch, array $query): void
curl_setopt($ch, CURLOPT_URL, self::URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/x-www-form-urlencoded'
]);
Expand Down
2 changes: 1 addition & 1 deletion tests/Analytics/AnalyticsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class AnalyticsTest extends TestCase
{
public GoogleAnalytics $ga;
public $ga;

public function setUp(): void
{
Expand Down

0 comments on commit adfc2d0

Please sign in to comment.