kollapsminoriteten/wp-includes/SimplePie/src/Rating.php

90 lines
1.8 KiB
PHP
Raw Normal View History

2019-11-02 10:38:58 +01:00
<?php
2025-02-28 08:42:11 +01:00
2025-12-12 13:15:55 +01:00
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
2019-11-02 10:38:58 +01:00
2025-02-28 08:42:11 +01:00
namespace SimplePie;
2019-11-02 10:38:58 +01:00
/**
* Handles `<media:rating>` or `<itunes:explicit>` tags as defined in Media RSS and iTunes RSS respectively
*
2025-02-28 08:42:11 +01:00
* Used by {@see \SimplePie\Enclosure::get_rating()} and {@see \SimplePie\Enclosure::get_ratings()}
2019-11-02 10:38:58 +01:00
*
2025-02-28 08:42:11 +01:00
* This class can be overloaded with {@see \SimplePie\SimplePie::set_rating_class()}
2019-11-02 10:38:58 +01:00
*/
2025-02-28 08:42:11 +01:00
class Rating
2019-11-02 10:38:58 +01:00
{
2025-02-28 08:42:11 +01:00
/**
* Rating scheme
*
2025-12-12 13:15:55 +01:00
* @var ?string
2025-02-28 08:42:11 +01:00
* @see get_scheme()
*/
public $scheme;
2019-11-02 10:38:58 +01:00
2025-02-28 08:42:11 +01:00
/**
* Rating value
*
2025-12-12 13:15:55 +01:00
* @var ?string
2025-02-28 08:42:11 +01:00
* @see get_value()
*/
public $value;
2019-11-02 10:38:58 +01:00
2025-02-28 08:42:11 +01:00
/**
* Constructor, used to input the data
*
* For documentation on all the parameters, see the corresponding
* properties and their accessors
*/
2025-12-12 13:15:55 +01:00
public function __construct(
?string $scheme = null,
?string $value = null
) {
2025-02-28 08:42:11 +01:00
$this->scheme = $scheme;
$this->value = $value;
}
2019-11-02 10:38:58 +01:00
2025-02-28 08:42:11 +01:00
/**
* String-ified version
*
* @return string
*/
public function __toString()
{
// There is no $this->data here
return md5(serialize($this));
}
2019-11-02 10:38:58 +01:00
2025-02-28 08:42:11 +01:00
/**
* Get the organizational scheme for the rating
*
* @return string|null
*/
public function get_scheme()
{
if ($this->scheme !== null) {
return $this->scheme;
}
2020-09-15 14:29:22 +02:00
2025-02-28 08:42:11 +01:00
return null;
}
2019-11-02 10:38:58 +01:00
2025-02-28 08:42:11 +01:00
/**
* Get the value of the rating
*
* @return string|null
*/
public function get_value()
{
if ($this->value !== null) {
return $this->value;
}
2020-09-15 14:29:22 +02:00
2025-02-28 08:42:11 +01:00
return null;
}
2019-11-02 10:38:58 +01:00
}
2025-02-28 08:42:11 +01:00
class_alias('SimplePie\Rating', 'SimplePie_Rating');