$value){ if(!property_exists(self::class,$key)) { unset($config[$key]); } elseif($value==null || $value===false || $value=='') { unset($config[$key]); } } $this->constructArray=$config; parent::__construct($config); } public function createJson() { } public function toJson(): string { $resultJson=" '; return $resultJson; } function add($key,$value) { if ($value!==null) $this->constructArray[$key]=$value; } public function test() { #Для страниц услуг где представлена только одна цена $productArray=[ 'type'=>'Product', 'name'=> 'Executive Anvil', 'image'=> [ 'https://example.com/photos/1x1/photo.jpg', 'https://example.com/photos/4x3/photo.jpg', 'https://example.com/photos/16x9/photo.jpg' ], 'description'=>'Sleeker than ACME\'s Classic Anvil, the Executive Anvil is perfect for the business traveler looking for something to drop from a height.', 'mpn'=>'925872', 'brand'=>[ 'type'=> 'Thing', 'name'=> 'ACME' ], 'aggregateRating'=> [ 'type'=> 'AggregateRating', 'ratingValue'=> '4.4', 'reviewCount'=> '89' ], 'offers'=> [ '@type'=> 'Offer', 'priceCurrency'=> 'USD', 'Price'=> '199.99', 'priceValidUntil'=> '2020-11-05', 'itemCondition'=> 'http://schema.org/UsedCondition', 'availability'=> 'http://schema.org/InStock', 'seller'=> [ 'type'=> 'Organization', 'name'=>'Executive Objects'] ] ]; #Для страниц услуг где представлены 2 и больше цен $layout2= [ '@context'=> 'http://schema.org/', '@type'=> 'Product', 'name'=> 'Executive Anvil', 'image'=> [ 'https://example.com/photos/1x1/photo.jpg', 'https://example.com/photos/4x3/photo.jpg', 'https://example.com/photos/16x9/photo.jpg' ], 'brand'=> [ '@type'=> 'Thing', 'name'=> 'ACME' ], 'aggregateRating'=> [ '@type'=> 'AggregateRating', 'ratingValue'=> '4.4', 'ratingCount'=> '89' ], 'offers' => [ '@type'=> 'AggregateOffer', 'lowPrice'=> '119.99', 'highPrice'=> '199.99', 'priceCurrency'=> 'USD' ] ]; } }