From 3410c079723c1d8fdf39853fee87249265d7b69b Mon Sep 17 00:00:00 2001 From: Percy Mamedy Date: Thu, 28 Nov 2019 17:26:52 +0400 Subject: [PATCH 1/5] Issue #11 - Added a public name() method to the Target Object. - Fixed conflict of __call method on Target Object. --- src/Metrics/Target.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Metrics/Target.php b/src/Metrics/Target.php index 6eee671..9a10398 100644 --- a/src/Metrics/Target.php +++ b/src/Metrics/Target.php @@ -9,7 +9,9 @@ class Target implements UrlParameter, Metric { - use Makable, Macroable; + use Makable, Macroable { + Macroable::__call as callMacro; + } /** * Name for the target. @@ -62,6 +64,16 @@ public function apply(string $method, ...$args): Metric return $this; } + /** + * Returns the name of the Target. + * + * @return string + */ + public function name(): string + { + return $this->name; + } + /** * Get the current value of the parameter as string for Graphite. * @@ -92,7 +104,11 @@ public function render(): string */ public function __call($name, $arguments) { - return $this->apply($name, ...$arguments); + try { + return $this->callMacro($name, $arguments); + } catch (\BadMethodCallException $e) { + return $this->apply($name, ...$arguments); + } } /** From 1307ab44e5131a9f359f428a4216f252efa92610 Mon Sep 17 00:00:00 2001 From: Percy Mamedy Date: Thu, 28 Nov 2019 17:39:06 +0400 Subject: [PATCH 2/5] Issue #10 - Added public methods on the Point object to access time and value. - Made the Point Object Macroable for more flexibility. --- src/Series/Point.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Series/Point.php b/src/Series/Point.php index c8fa2a9..6aef0a5 100644 --- a/src/Series/Point.php +++ b/src/Series/Point.php @@ -3,9 +3,12 @@ namespace OceanDBA\Graphitti\Series; use Illuminate\Support\Carbon; +use Illuminate\Support\Traits\Macroable; class Point { + use Macroable; + /** * Time at which the point occurred. * @@ -32,6 +35,27 @@ public function __construct(Carbon $time, float $value) $this->value = $value; } + /** + * Get the time for this Point. + * + * @return Carbon + */ + public function time(): Carbon + { + return $this->time; + } + + + /** + * Get the value of the Point. + * + * @return float + */ + public function value(): float + { + return $this->value; + } + /** * Create a new Point using raw values. * From f16da140dc631fea5fde539c84b5fe9884a40594 Mon Sep 17 00:00:00 2001 From: Percy Mamedy Date: Thu, 28 Nov 2019 13:40:39 +0000 Subject: [PATCH 3/5] Apply fixes from StyleCI --- src/Series/Point.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Series/Point.php b/src/Series/Point.php index 6aef0a5..4fa8fc8 100644 --- a/src/Series/Point.php +++ b/src/Series/Point.php @@ -45,7 +45,6 @@ public function time(): Carbon return $this->time; } - /** * Get the value of the Point. * From 5bb6511b8387b2cbe8657f93c3785a0e380c4195 Mon Sep 17 00:00:00 2001 From: Percy Mamedy Date: Fri, 29 Nov 2019 09:13:45 +0400 Subject: [PATCH 4/5] Issue #9 - Added a public method to access points collection in the DataPoints Object. --- src/Series/DataPoints.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Series/DataPoints.php b/src/Series/DataPoints.php index d03aad8..aec0393 100644 --- a/src/Series/DataPoints.php +++ b/src/Series/DataPoints.php @@ -56,6 +56,16 @@ public static function make(Target $target, array $data = null): self return new static($target, $points); } + /** + * Returns the points Collection. + * + * @return Collection + */ + public function points(): Collection + { + return $this->points; + } + /** * Determine if the datapoints is empty or not. * From 9aaa675b301c4501726adfa6190a7719153545e8 Mon Sep 17 00:00:00 2001 From: Percy Mamedy Date: Fri, 29 Nov 2019 09:24:48 +0400 Subject: [PATCH 5/5] Issue#8 - Added target method to DataPoints object. --- src/Series/DataPoints.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Series/DataPoints.php b/src/Series/DataPoints.php index aec0393..b555fc0 100644 --- a/src/Series/DataPoints.php +++ b/src/Series/DataPoints.php @@ -56,6 +56,16 @@ public static function make(Target $target, array $data = null): self return new static($target, $points); } + /** + * Returns the Target associated to the DataPoints. + * + * @return Target + */ + public function target(): Target + { + return $this->target; + } + /** * Returns the points Collection. *