Boundaries.php
2 years ago
Cast.php
2 years ago
Comparison.php
1 year ago
Converter.php
2 years ago
Creator.php
2 years ago
Date.php
1 month ago
DeprecatedProperties.php
2 years ago
Difference.php
2 years ago
IntervalRounding.php
2 years ago
IntervalStep.php
2 years ago
Localization.php
1 month ago
Macro.php
2 years ago
MagicParameter.php
2 years ago
Mixin.php
2 years ago
Modifiers.php
2 years ago
Mutability.php
2 years ago
ObjectInitialisation.php
2 years ago
Options.php
1 year ago
Rounding.php
2 years ago
Serialization.php
2 years ago
Test.php
1 month ago
Timestamp.php
1 month ago
ToStringFormat.php
2 years ago
Units.php
2 years ago
Week.php
2 years ago
MagicParameter.php
32 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This file is part of the Carbon package. |
| 5 | * |
| 6 | * (c) Brian Nesbitt <brian@nesbot.com> |
| 7 | * |
| 8 | * For the full copyright and license information, please view the LICENSE |
| 9 | * file that was distributed with this source code. |
| 10 | */ |
| 11 | namespace IAWPSCOPED\Carbon\Traits; |
| 12 | |
| 13 | /** |
| 14 | * Trait MagicParameter. |
| 15 | * |
| 16 | * Allows to retrieve parameter in magic calls by index or name. |
| 17 | * @internal |
| 18 | */ |
| 19 | trait MagicParameter |
| 20 | { |
| 21 | private function getMagicParameter(array $parameters, int $index, string $key, $default) |
| 22 | { |
| 23 | if (\array_key_exists($index, $parameters)) { |
| 24 | return $parameters[$index]; |
| 25 | } |
| 26 | if (\array_key_exists($key, $parameters)) { |
| 27 | return $parameters[$key]; |
| 28 | } |
| 29 | return $default; |
| 30 | } |
| 31 | } |
| 32 |