-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from EXayer/duplicate-key-config-support
Ability to format duplicate keys
- Loading branch information
Showing
13 changed files
with
206 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace EXayer\VdfConverter\UniqueKey; | ||
|
||
class DefaultFormatter implements Formatter | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function buildKeyName(string $key, int $index): string | ||
{ | ||
return $key . '__[' . $index . ']'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace EXayer\VdfConverter\UniqueKey; | ||
|
||
interface Formatter | ||
{ | ||
/** | ||
* Returns a formatted key based on original key and duplicate index. | ||
* | ||
* @param string $key Original key. | ||
* @param int $index Duplicate key index. | ||
* | ||
* @return string | ||
*/ | ||
public function buildKeyName(string $key, int $index): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace EXayer\VdfConverter; | ||
|
||
use EXayer\VdfConverter\UniqueKey\DefaultFormatter; | ||
use EXayer\VdfConverter\UniqueKey\Formatter; | ||
|
||
class VdfConverterConfig | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $uniqueKeyFormatter = DefaultFormatter::class; | ||
|
||
/** | ||
* @return self | ||
*/ | ||
public static function create(): self | ||
{ | ||
return new self(); | ||
} | ||
|
||
/** | ||
* @param string $formatterClassName | ||
* | ||
* @return $this | ||
*/ | ||
public function uniqueKeyFormatter(string $formatterClassName): self | ||
{ | ||
$this->uniqueKeyFormatter = $formatterClassName; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return Formatter | ||
*/ | ||
public function getUniqueKeyFormatter(): Formatter | ||
{ | ||
return new $this->uniqueKeyFormatter; | ||
} | ||
} |
Oops, something went wrong.