Skip to content

Make setters fluent #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/Chartjs/Model/Chart.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,34 @@ public function __construct(string $type)
$this->type = $type;
}

public function setData(array $data)
/**
* @return $this
*/
public function setData(array $data): self
{
$this->data = $data;

return $this;
}

public function setOptions(array $options)
/**
* @return $this
*/
public function setOptions(array $options): self
{
$this->options = $options;

return $this;
}

public function setAttributes(array $attributes)
/**
* @return $this
*/
public function setAttributes(array $attributes): self
{
$this->attributes = $attributes;

return $this;
}

public function createView(): array
Expand Down
21 changes: 18 additions & 3 deletions src/Cropperjs/Model/Crop.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,38 @@ public function getOptions(): string
return json_encode($this->options);
}

public function setOptions(string $options)
/**
* @return $this
*/
public function setOptions(string $options): self
{
$this->options = json_decode($options, true);

return $this;
}

public function setDefaultOptions(array $options)
/**
* @return $this
*/
public function setDefaultOptions(array $options): self
{
foreach ($this->options as $key => $defaultValue) {
if (isset($options[$key])) {
$this->options[$key] = $options[$key];
}
}

return $this;
}

public function setCroppedMaxSize(int $maxWidth, int $maxHeight)
/**
* @return $this
*/
public function setCroppedMaxSize(int $maxWidth, int $maxHeight): self
{
$this->maxWidth = $maxWidth;
$this->maxHeight = $maxHeight;

return $this;
}
}