| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Exceptions; |
| 4 |
|
| 5 |
use RuntimeException; |
| 6 |
|
| 7 |
/** |
| 8 |
* Exception for attempting a mutation on properties that are made readonly through magic getters and setters. |
| 9 |
*/ |
| 10 |
class Forbidden_Property_Mutation_Exception extends RuntimeException { |
| 11 |
|
| 12 |
/** |
| 13 |
* Creates a Forbidden_Property_Mutation_Exception exception when an attempt is made |
| 14 |
* to assign a value to an immutable property. |
| 15 |
* |
| 16 |
* @param string $property_name The name of the immutable property. |
| 17 |
* |
| 18 |
* @return Forbidden_Property_Mutation_Exception The exception. |
| 19 |
*/ |
| 20 |
public static function cannot_set_because_property_is_immutable( $property_name ) { |
| 21 |
return new self( \sprintf( 'Setting property $%s is not supported.', $property_name ) ); |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* Creates a Forbidden_Property_Mutation_Exception exception when an attempt is made to unset an immutable property. |
| 26 |
* |
| 27 |
* @param string $property_name The name of the immutable property. |
| 28 |
* |
| 29 |
* @return Forbidden_Property_Mutation_Exception The exception. |
| 30 |
*/ |
| 31 |
public static function cannot_unset_because_property_is_immutable( $property_name ) { |
| 32 |
return new self( \sprintf( 'Unsetting property $%s is not supported.', $property_name ) ); |
| 33 |
} |
| 34 |
} |
| 35 |
|