generated from vormkracht10/laravel-package-template
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Minute range trait for realtime analytics * Fix styling * wip * Fix styling * wip * wip * wip * wip * Fix styling * wip * wip * wip * wip * wip * wip * wip * Type hint items --------- Co-authored-by: Baspa <[email protected]>
- Loading branch information
Showing
6 changed files
with
98 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace Vormkracht10\Analytics\Traits\Google; | ||
|
||
use Google\Analytics\Data\V1beta\MinuteRange; | ||
|
||
trait MinuteRangeTrait | ||
{ | ||
public array $minuteRanges = []; | ||
|
||
public function setMinuteRange(?string $name, ?int $start, ?int $end): self | ||
{ | ||
$this->minuteRanges = [ | ||
new MinuteRange([ | ||
'name' => $name, | ||
'start_minutes_ago' => $start, | ||
'end_minutes_ago' => $end, | ||
]), | ||
]; | ||
|
||
return $this; | ||
} | ||
|
||
public function setMinuteRanges(array ...$items): self | ||
{ | ||
$this->minuteRanges = []; | ||
|
||
foreach ($items as $item) { | ||
$this->minuteRanges[] = new MinuteRange([ | ||
'name' => $item['name'], | ||
'start_minutes_ago' => $item['start'], | ||
'end_minutes_ago' => $item['end'], | ||
]); | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
private function validateStartAndEnd(?int $start, ?int $end): void | ||
{ | ||
if ($start > $end) { | ||
throw new \Exception('Start cannot be greater than end'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters