Skip to content

Commit f678c9a

Browse files
committed
More inline documentation
1 parent 6d2c401 commit f678c9a

File tree

2 files changed

+49
-5
lines changed

2 files changed

+49
-5
lines changed

src/Chart.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,21 @@ public function __construct()
2222
$this->data = new Data();
2323
}
2424

25+
/**
26+
* Get the chart as an array
27+
*
28+
* @return array
29+
*/
2530
public function get(): array
2631
{
2732
return $this->toArray();
2833
}
2934

35+
/**
36+
* Convert the chart to an array
37+
*
38+
* @return array
39+
*/
3040
public function toArray(): array
3141
{
3242
return [
@@ -36,18 +46,35 @@ public function toArray(): array
3646
];
3747
}
3848

49+
/**
50+
* Convert the chart to JSON
51+
*
52+
* @return string
53+
*/
3954
public function toJson(): string
4055
{
4156
return json_encode($this->toArray(), true);
4257
}
4358

59+
/**
60+
* Set the chart options
61+
*
62+
* @param Options $options
63+
* @return self
64+
*/
4465
public function options(Options $options): self
4566
{
4667
$this->options = $options;
4768

4869
return $this;
4970
}
5071

72+
/**
73+
* Set the chart data
74+
*
75+
* @param Data $data
76+
* @return self
77+
*/
5178
public function data(Data $data): self
5279
{
5380
$this->data = $data;
@@ -57,6 +84,8 @@ public function data(Data $data): self
5784

5885
/**
5986
* Helper to generate beginAtZero configuration
87+
*
88+
* @return self
6089
*/
6190
public function beginAtZero(): self
6291
{
@@ -73,6 +102,13 @@ public function beginAtZero(): self
73102
return $this;
74103
}
75104

105+
/**
106+
* Generate the HTML representation of the chart
107+
*
108+
* @param string $element
109+
* @param Chart $chart
110+
* @return string
111+
*/
76112
public function toHtml(string $element, Chart $chart = null): string
77113
{
78114
if ($chart === null) {

src/Config/Config.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ public function __construct(array $attributes = [])
1212
}
1313

1414
/**
15-
* @param $name
15+
* Get the value of a property.
1616
*
17+
* @param string $name
1718
* @return mixed
1819
*/
1920
public function __get($name)
@@ -22,9 +23,10 @@ public function __get($name)
2223
}
2324

2425
/**
25-
* @param $name
26-
* @param $value
26+
* Set the value of a property.
2727
*
28+
* @param string $name
29+
* @param mixed $value
2830
* @return $this
2931
*/
3032
public function __set($name, $value)
@@ -35,16 +37,22 @@ public function __set($name, $value)
3537
}
3638

3739
/**
38-
* @param $name
39-
* @param $value
40+
* Dynamically set the value of a property.
4041
*
42+
* @param string $name
43+
* @param mixed $value
4144
* @return $this
4245
*/
4346
public function __call($name, $value)
4447
{
4548
return $this->__set($name, reset($value));
4649
}
4750

51+
/**
52+
* Convert the object to an array.
53+
*
54+
* @return array
55+
*/
4856
public function toArray(): array
4957
{
5058
array_walk_recursive($this->attributes, function (&$item) {

0 commit comments

Comments
 (0)