Skip to content
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: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ use Stillat\Proteus\Support\Facades\ConfigWriter;
$document = ConfigWriter::edit('app')
->set([
'locale' => 'fr',
'timezone' => 'Europe/Paris'
'timezone' => 'Europe/Paris'
])->preview();
```

Expand All @@ -176,7 +176,7 @@ use Stillat\Proteus\Support\Facades\ConfigWriter;
ConfigWriter::edit('app')
->set([
'locale' => 'fr',
'timezone' => 'Europe/Paris'
'timezone' => 'Europe/Paris'
])->save();
```

Expand Down Expand Up @@ -237,7 +237,7 @@ use Stillat\Proteus\Support\Facades\ConfigWriter;
ConfigWriter::edit('app')
->set([
'locale' => 'fr',
'timezone' => 'Europe/Paris'
'timezone' => 'Europe/Paris'
])->merge('providers', [
SomeProvider::class,
SomeOtherProvider::class
Expand Down Expand Up @@ -295,6 +295,19 @@ ConfigWriter::write('custom.path', ConfigWriter::f()->publicPath('relative'));
ConfigWriter::write('custom.path', ConfigWriter::f()->resourcePath('relative'));
```

You may also call other **globally registered** functions:

```php
<?php
use Stillat\Proteus\Support\Facades\ConfigWriter;

function my_custom_function($paramOne, $paramTwo) {
...
}

ConfigWriter::write('custom.path', ConfigWriter::f()->makeSimpleFunctionCall('my_custom_function', [$one, $two]));
```

## Advanced Usage

Given the following input configuration file:
Expand Down Expand Up @@ -323,7 +336,7 @@ $updater->update([
'hello',
'world'
]
]
]
]
]
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Writers/FunctionWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class FunctionWriter

const FUNC_LARAVEL_ENV = 'env';

protected function makeSimpleFunctionCall(string $name, string|array $args): FuncCall
public function makeSimpleFunctionCall(string $name, string|array $args): FuncCall
{
return new FuncCall(
$this->convertToName($name),
Expand Down
16 changes: 16 additions & 0 deletions tests/LaravelFunctionCallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ public function testExistingEnvCallsCanBeReplaced()
);
}

public function testCustomCallsCanBeWritten()
{
$f = new FunctionWriter();

$this->assertChangeEquals(
__DIR__.'/configs/empty.php',
__DIR__.'/expected/newenv.php',
[
'thing' => $f->makeSimpleFunctionCall('env', ['APP_NAME', 'Laravel']),
'thing2' => $f->makeSimpleFunctionCall('env', 'Something'),
]
);
}



public function testWritingNewClosuresOrArrowFunctions()
{
$f = new FunctionWriter();
Expand Down