Skip to content

Commit

Permalink
Merge pull request #17 from oceandba/release/v1.0.1
Browse files Browse the repository at this point in the history
Release v1.0.1
  • Loading branch information
percymamedy authored Nov 29, 2019
2 parents d96d165 + a3e5df1 commit 0c08532
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/Metrics/Target.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

class Target implements UrlParameter, Metric
{
use Makable, Macroable;
use Makable, Macroable {
Macroable::__call as callMacro;
}

/**
* Name for the target.
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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);
}
}

/**
Expand Down
20 changes: 20 additions & 0 deletions src/Series/DataPoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,26 @@ 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.
*
* @return Collection
*/
public function points(): Collection
{
return $this->points;
}

/**
* Determine if the datapoints is empty or not.
*
Expand Down
23 changes: 23 additions & 0 deletions src/Series/Point.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -32,6 +35,26 @@ 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.
*
Expand Down

0 comments on commit 0c08532

Please sign in to comment.