PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 27.6
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v27.6
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / exceptions / forbidden-property-mutation-exception.php

forbidden-property-mutation-exception.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 27.6, at src/exceptions/forbidden-property-mutation-exception.php

35 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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