Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../public_h.../wp-conte.../plugins/wordpres.../src/presenta...
File: abstract-presentation.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Presentations;
[2] Fix | Delete
[3] Fix | Delete
use AllowDynamicProperties;
[4] Fix | Delete
use Exception;
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* The abstract presentation class.
[8] Fix | Delete
*/
[9] Fix | Delete
#[AllowDynamicProperties]
[10] Fix | Delete
class Abstract_Presentation {
[11] Fix | Delete
[12] Fix | Delete
/**
[13] Fix | Delete
* The model.
[14] Fix | Delete
*
[15] Fix | Delete
* @var mixed
[16] Fix | Delete
*/
[17] Fix | Delete
public $model;
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* Whether or not there is a presentation prototype.
[21] Fix | Delete
*
[22] Fix | Delete
* @var bool
[23] Fix | Delete
*/
[24] Fix | Delete
private $is_prototype = true;
[25] Fix | Delete
[26] Fix | Delete
/**
[27] Fix | Delete
* Creates a model presentation.
[28] Fix | Delete
*
[29] Fix | Delete
* @param array $data The data that this is a presentation of.
[30] Fix | Delete
*
[31] Fix | Delete
* @return static A model presentation.
[32] Fix | Delete
*
[33] Fix | Delete
* @throws Exception If attempting to create a model presentation from another model presentation.
[34] Fix | Delete
*/
[35] Fix | Delete
public function of( $data ) {
[36] Fix | Delete
if ( ! $this->is_prototype() ) {
[37] Fix | Delete
throw new Exception( 'Attempting to create a model presentation from another model presentation. Use the prototype presentation gained from DI instead.' );
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
// Clone self to allow stateful services that do benefit from DI.
[41] Fix | Delete
$presentation = clone $this;
[42] Fix | Delete
foreach ( $data as $key => $value ) {
[43] Fix | Delete
$presentation->{$key} = $value;
[44] Fix | Delete
}
[45] Fix | Delete
$presentation->is_prototype = false;
[46] Fix | Delete
return $presentation;
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* Magic getter for lazy loading of generate functions.
[51] Fix | Delete
*
[52] Fix | Delete
* @param string $name The property to get.
[53] Fix | Delete
*
[54] Fix | Delete
* @return mixed The value if it could be generated.
[55] Fix | Delete
*
[56] Fix | Delete
* @throws Exception If there is no generator for the property.
[57] Fix | Delete
*/
[58] Fix | Delete
public function __get( $name ) {
[59] Fix | Delete
if ( $this->is_prototype() ) {
[60] Fix | Delete
throw new Exception( 'Attempting property access on prototype presentation. Use Presentation::of( $data ) to get a model presentation.' );
[61] Fix | Delete
}
[62] Fix | Delete
$generator = "generate_$name";
[63] Fix | Delete
if ( \method_exists( $this, $generator ) ) {
[64] Fix | Delete
$this->{$name} = $this->$generator();
[65] Fix | Delete
return $this->{$name};
[66] Fix | Delete
}
[67] Fix | Delete
throw new Exception( "Property $name has no generator. Expected function $generator." );
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
/**
[71] Fix | Delete
* Magic isset for ensuring methods that have a generator are recognised.
[72] Fix | Delete
*
[73] Fix | Delete
* @codeCoverageIgnore Wrapper method.
[74] Fix | Delete
*
[75] Fix | Delete
* @param string $name The property to get.
[76] Fix | Delete
*
[77] Fix | Delete
* @return bool Whether or not there is a generator for the requested property.
[78] Fix | Delete
*/
[79] Fix | Delete
public function __isset( $name ) {
[80] Fix | Delete
return \method_exists( $this, "generate_$name" );
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
/**
[84] Fix | Delete
* Returns `true` if this class is a prototype.
[85] Fix | Delete
*
[86] Fix | Delete
* @codeCoverageIgnore Wrapper method.
[87] Fix | Delete
*
[88] Fix | Delete
* @return bool If this class is a prototype or not.
[89] Fix | Delete
*/
[90] Fix | Delete
protected function is_prototype() {
[91] Fix | Delete
return $this->is_prototype;
[92] Fix | Delete
}
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function