Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudio-Emmolo authored and github-actions[bot] committed Jul 31, 2024
1 parent c184200 commit b2de4b2
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/CloudflareAnalytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,29 @@

namespace The3LabsTeam\PhpCloudflareAnalytics;

class CloudflareAnalytics {

class CloudflareAnalytics
{
public string $api_token;

public string $endpoint;

public function __construct() {
public function __construct()
{
$this->api_token = env('CLOUDFLARE_API_TOKEN');
$this->endpoint = "https://api.cloudflare.com/client/v4/graphql";
$this->endpoint = 'https://api.cloudflare.com/client/v4/graphql';
}

protected function graphQLQuery($query) {
protected function graphQLQuery($query)
{
$ch = curl_init($this->endpoint);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode(['query' => $query]),
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Authorization: Bearer ' . $this->api_token
]
'Authorization: Bearer '.$this->api_token,
],
]);

$response = curl_exec($ch);
Expand All @@ -32,12 +35,11 @@ protected function graphQLQuery($query) {

/**
* Get the views between two dates - Returns an array with the date as key and the views as value
* @param $startDate
* @param $endDate
* @param $zoneTag
*
* @return array
*/
public function getViewsBetweenDates($startDate, $endDate, $zoneTag) {
public function getViewsBetweenDates($startDate, $endDate, $zoneTag)
{
$query = <<<GRAPHQL
query {
viewer {
Expand Down Expand Up @@ -71,18 +73,16 @@ public function getViewsBetweenDates($startDate, $endDate, $zoneTag) {
//order by date
ksort($parsedResponse);


return $parsedResponse;
}

/**
* Get the total views between two dates - Returns the total views
* @param $startDate
* @param $endDate
* @param $zoneTag
*
* @return int|mixed
*/
public function getTotalViewsBetweenDates($startDate, $endDate, $zoneTag) {
public function getTotalViewsBetweenDates($startDate, $endDate, $zoneTag)
{
$query = <<<GRAPHQL
query {
viewer {
Expand Down

0 comments on commit b2de4b2

Please sign in to comment.