DEV Community

Sanjit Kung
Sanjit Kung

Posted on

Method naming conventions I use to either merge or replace the instance values

Lets say I have an instance variable in a class that holds an array of strings

private $scopes = [];
Enter fullscreen mode Exit fullscreen mode

To merge given scopes into existing scopes

public function scopes(array $scopes)
Enter fullscreen mode Exit fullscreen mode

Completely replace scopes array with new items

public function setScopes(array $scopes): void
Enter fullscreen mode Exit fullscreen mode

Get the current scopes

public function getScopes(): array
Enter fullscreen mode Exit fullscreen mode

Top comments (0)