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

114 lines
2.1 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:credit>` as defined in Media RSS
*
2025-02-28 08:42:11 +01:00
* Used by {@see \SimplePie\Enclosure::get_credit()} and {@see \SimplePie\Enclosure::get_credits()}
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_credit_class()}
2019-11-02 10:38:58 +01:00
*/
2025-02-28 08:42:11 +01:00
class Credit
2019-11-02 10:38:58 +01:00
{
2025-02-28 08:42:11 +01:00
/**
* Credited role
*
2025-12-12 13:15:55 +01:00
* @var ?string
2025-02-28 08:42:11 +01:00
* @see get_role()
*/
public $role;
2019-11-02 10:38:58 +01:00
2025-02-28 08:42:11 +01:00
/**
* Organizational 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
/**
* Credited name
*
2025-12-12 13:15:55 +01:00
* @var ?string
2025-02-28 08:42:11 +01:00
* @see get_name()
*/
public $name;
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 $role = null,
?string $scheme = null,
?string $name = null
) {
2025-02-28 08:42:11 +01:00
$this->role = $role;
$this->scheme = $scheme;
$this->name = $name;
}
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 role of the person receiving credit
*
* @return string|null
*/
public function get_role()
{
if ($this->role !== null) {
return $this->role;
}
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 organizational scheme
*
* @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 credited person/entity's name
*
* @return string|null
*/
public function get_name()
{
if ($this->name !== null) {
return $this->name;
}
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\Credit', 'SimplePie_Credit');