Skip to content

Commit

Permalink
Add description and some comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyDune committed May 8, 2018
1 parent 9056f81 commit 9d00040
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,23 @@ $instance->one = 'swim';
$instance->replace($string); // equals to 'Gogoriki go swim
```

`comma` function may get params: `comma(param1, param2)`

- *param1* set to `1` if you want to miss first comma appearance in string
- *param2* set to `1` if you want to begin new group of words for next missing of first comma appearance in string

```php
$string = 'I know words: #it:addcomma(1)##and_it:addcomma(1)# and #and_it_2:addcomma(1, 1)#';
$instance = new PowerReplace();
$instance->setArray(
'it' => 'eat',
'and_it' = 'play',
'and_it_2' = 'sleep'
);
$instance->replace($string); // equals to 'I know words: eat, play and sleep'

```

### maxlen

Replace marker with value if string behind this one is less then poined in parameter.
Expand Down
4 changes: 4 additions & 0 deletions src/Functions/FunctionAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ abstract class FunctionAbstract
{
abstract public function __invoke($string);

/**
* Functions can accumulate some values for single string for handle.
* Useful for clear values in function objects.
*/
public function clear()
{

Expand Down
3 changes: 3 additions & 0 deletions src/FunctionsHolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ protected function getFunctionWithName($name)
}


/**
* Clear accumulated values for all created function instances.
*/
public function clear()
{
foreach ($this->functions as $function) {
Expand Down

0 comments on commit 9d00040

Please sign in to comment.