Source of file AbstractParameters.php
Size: 2,175 Bytes - Last Modified: 2021-01-12T22:04:13+00:00
C:/Users/MAKS/Code/_PROJECTS/amqp-agent/src/Config/AbstractParameters.php
| 1234567891011121314151617181920212223242526272829303132 
                                Covered by 71 test(s):
                            33 
 
                                Covered by 71 test(s):
                            3435 
 
                                Covered by 71 test(s):
                            36 
 
                                Covered by 70 test(s):
                            3738 
 
                                Covered by 70 test(s):
                            394041 
 
                                Covered by 71 test(s):
                            42 
 
                                Covered by 70 test(s):
                            434445 
 
                                Covered by 1 test(s):
                            46 
 
                                Covered by 1 test(s):
                            47 
 
                                Covered by 1 test(s):
                            48495051525354555657585960616263 
 
                                Covered by 70 test(s):
                            64 
 
                                Covered by 70 test(s):
                            65 
 
                                Covered by 70 test(s):
                            66 
 
                                Covered by 70 test(s):
                            676869707172 
 
                                Covered by 70 test(s):
                            737475 
 | <?php/** * @author Marwan Al-Soltany <MarwanAlsoltany@gmail.com> * @copyright Marwan Al-Soltany 2020 * For the full copyright and license information, please view * the LICENSE file that was distributed with this source code. */declare(strict_types=1); namespace MAKS\AmqpAgent\Config; use MAKS\AmqpAgent\Exception\ConstantDoesNotExistException; /** * An abstract class that exposes a simple API to work with parameters. * @since 1.2.0 */abstract class AbstractParameters {/**      * Patches the passed array with a class constant.     * @param array $options The partial array.     * @param string $const The constant name.     * @param bool $values Whether to return values only or an associative array.     * @return array The final patched array.     * @throws ConstantDoesNotExistException     */final public static function patch(array $options, string $const, bool $values = false): array { $final = null; $const = static::class . '::' . $const; if (defined($const)) { $const = constant($const); $final = is_array($const) ? self::patchWith($options, $const, $values) : $final; } if (null !== $final) { return $final; } throw new ConstantDoesNotExistException( sprintf( 'Could not find a constant with the name "%s", or the constant is not of type array!', $const ) ); } /**      * Patches the passed array with another array.     * @param array $partialArray The partial array.     * @param array $fullArray The full array.     * @param bool $values Whether to return values only or an associative array.     * @return array The final patched array.     */final public static function patchWith(array $partialArray, array $fullArray, bool $values = false): array { $final = ( array_merge( $fullArray, array_intersect_key( $partialArray, $fullArray ) ) ); return !$values ? $final : array_values($final); } } |