diff options
Diffstat (limited to 'bin/wiki/vendor/addwiki/mediawiki-datamodel/src')
14 files changed, 1370 insertions, 0 deletions
diff --git a/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Content.php b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Content.php new file mode 100644 index 00000000..c1372d46 --- /dev/null +++ b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Content.php @@ -0,0 +1,83 @@ +<?php + +namespace Mediawiki\DataModel; + +use LogicException; + +/** + * Class Representing the content of a revision + * @author Addshore + */ +class Content { + + /** + * @var string sha1 hash of the object content upon creation + */ + private $initialHash; + + /** + * @var mixed + */ + private $data; + + /** + * @var string|null + */ + private $model; + + /** + * Should always be called AFTER overriding constructors so a hash can be created + * + * @param mixed $data + * @param string|null $model + */ + public function __construct( $data, $model = null ) { + $this->data = $data; + $this->model = $model; + $this->initialHash = $this->getHash(); + } + + /** + * @return string + */ + public function getModel() { + return $this->model; + } + + /** + * Returns a sha1 hash of the content + * + * @throws LogicException + * @return string + */ + public function getHash() { + $data = $this->getData(); + if( is_object( $data ) ) { + if( method_exists( $data, 'getHash' ) ) { + return $data->getHash(); + } else { + return sha1( serialize( $data ) ); + } + } + if( is_string( $data ) ) { + return sha1( $data ); + } + throw new LogicException( "Cant get hash for data of type: " . gettype( $data ) ); + } + + /** + * Has the content been changed since object construction (this shouldn't happen!) + * @return bool + */ + public function hasChanged() { + return $this->initialHash !== $this->getHash(); + } + + /** + * @return mixed + */ + public function getData() { + return $this->data; + } + +}
\ No newline at end of file diff --git a/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/EditInfo.php b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/EditInfo.php new file mode 100644 index 00000000..b6ba7845 --- /dev/null +++ b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/EditInfo.php @@ -0,0 +1,79 @@ +<?php + +namespace Mediawiki\DataModel; + +use InvalidArgumentException; + +/** + * Represents flags that can be used when edits are made + * @author Addshore + */ +class EditInfo { + + //minor flags + const MINOR = true; + const NOTMINOR = false; + //bot flags + const BOT = true; + const NOTBOT = false; + + /** + * @var EditInfo::MINOR|self::NOTMINOR + */ + protected $minor = false; + + /** + * @var EditInfo::BOT|self::NOTBOT + */ + protected $bot = false; + + /** + * @var string + */ + protected $summary = null; + + /** + * @param string $summary + * @param bool $minor + * @param bool $bot + * + * @throws InvalidArgumentException + */ + public function __construct( $summary = '', $minor = self::NOTMINOR, $bot = self::NOTBOT ) { + if( !is_string( $summary ) ) { + throw new InvalidArgumentException( '$summary must be a string' ); + } + if( !is_bool( $minor ) ) { + throw new InvalidArgumentException( '$minor must be a bool' ); + } + if( !is_bool( $bot ) ) { + throw new InvalidArgumentException( '$bot must be a bool' ); + } + + $this->summary = $summary; + $this->bot = $bot; + $this->minor = $minor; + } + + /** + * @return EditInfo::BOT|self::NOTBOT + */ + public function getBot() { + return $this->bot; + } + + /** + * @return EditInfo::MINOR|self::NOTMINOR + */ + public function getMinor() { + return $this->minor; + } + + /** + * @return string + */ + public function getSummary() { + return $this->summary; + } + +}
\ No newline at end of file diff --git a/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/File.php b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/File.php new file mode 100644 index 00000000..7851b3b8 --- /dev/null +++ b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/File.php @@ -0,0 +1,37 @@ +<?php + +namespace Mediawiki\DataModel; + +use InvalidArgumentException; + +/** + * @author Addshore + */ +class File extends Page { + + /** + * @var string + */ + private $url; + + /** + * @param string $url + * @param PageIdentifier $pageIdentifier + * @param Revisions $revisions + */ + public function __construct( $url, PageIdentifier $pageIdentifier = null, Revisions $revisions = null ) { + parent::__construct( $pageIdentifier, $revisions ); + if( !is_string( $url ) ) { + throw new InvalidArgumentException( '$url must be a string' ); + } + $this->url = $url; + } + + /** + * @return string + */ + public function getUrl() { + return $this->url; + } + +}
\ No newline at end of file diff --git a/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Log.php b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Log.php new file mode 100644 index 00000000..d3e48637 --- /dev/null +++ b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Log.php @@ -0,0 +1,171 @@ +<?php + +namespace Mediawiki\DataModel; + +use JsonSerializable; + +/** + * @since 0.5 + */ +class Log implements JsonSerializable { + + /** + * @var int + */ + private $id; + + /** + * @var string + */ + private $type; + + /** + * @var string + */ + private $action; + + /** + * @var string + */ + private $timestamp; + + /** + * @var string + */ + private $user; + + /** + * @var string + */ + private $comment; + + /** + * @var PageIdentifier + */ + private $pageIdentifier; + + /** + * @var array + */ + private $details; + + /** + * @param int $id + * @param string $type + * @param string $action + * @param string $timestamp + * @param string $user + * @param PageIdentifier $pageIdentifier + * @param string $comment + * @param array $details + */ + public function __construct( $id, $type, $action, $timestamp, $user, $pageIdentifier, $comment, $details ) { + $this->id = $id; + $this->type = $type; + $this->action = $action; + $this->timestamp = $timestamp; + $this->user = $user; + $this->pageIdentifier = $pageIdentifier; + $this->comment = $comment; + $this->details = $details; + } + + /** + * @since 0.5 + * @return string + */ + public function getUser() { + return $this->user; + } + + /** + * @since 0.5 + * @return string + */ + public function getAction() { + return $this->action; + } + + /** + * @since 0.5 + * @return string + */ + public function getComment() { + return $this->comment; + } + + /** + * @since 0.5 + * @return int + */ + public function getId() { + return $this->id; + } + + /** + * @since 0.6 + * @return PageIdentifier + */ + public function getPageIdentifier() { + return $this->pageIdentifier; + } + + /** + * @since 0.5 + * @return string + */ + public function getTimestamp() { + return $this->timestamp; + } + + /** + * @since 0.5 + * @return string + */ + public function getType() { + return $this->type; + } + + /** + * @since 0.5 + * @return array + */ + public function getDetails() { + return $this->details; + } + + /** + * @link http://php.net/manual/en/jsonserializable.jsonserialize.php + */ + public function jsonSerialize() { + return array( + 'id' => $this->id, + 'type' => $this->type, + 'action' => $this->action, + 'timestamp' => $this->timestamp, + 'user' => $this->user, + 'pageidentifier' => $this->pageIdentifier, + 'comment' => $this->comment, + 'details' => $this->details, + ); + } + + /** + * @param array $json + * + * @return self + */ + public static function jsonDeserialize( $json ) { + return new self( + $json['id'], + $json['type'], + $json['action'], + $json['timestamp'], + $json['user'], + PageIdentifier::jsonDeserialize( $json['pageidentifier'] ), + $json['comment'], + $json['details'] + ); + } + +}
\ No newline at end of file diff --git a/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/LogList.php b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/LogList.php new file mode 100644 index 00000000..9ce30263 --- /dev/null +++ b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/LogList.php @@ -0,0 +1,138 @@ +<?php + +namespace Mediawiki\DataModel; + +use InvalidArgumentException; +use JsonSerializable; +use RuntimeException; + +/** + * Represents a collection of Log classes + * @author Addshore + */ +class LogList implements JsonSerializable { + + /** + * @var Log[] + */ + private $logs; + + /** + * @param Log[] $logs + */ + public function __construct( $logs = array() ) { + $this->logs = array(); + $this->addLogs( $logs ); + } + + /** + * @param Log[]|LogList $logs + * + * @throws InvalidArgumentException + */ + public function addLogs( $logs ) { + if( !is_array( $logs ) && !$logs instanceof LogList ) { + throw new InvalidArgumentException( '$logs needs to either be an array or a LogList object' ); + } + if( $logs instanceof LogList ) { + $logs = $logs->toArray(); + } + foreach( $logs as $log ) { + $this->addLog( $log ); + } + } + + /** + * @param Log $log + */ + public function addLog( Log $log ) { + $this->logs[$log->getId()] = $log; + } + + /** + * @param int $id + * + * @return bool + */ + public function hasLogWithId( $id ){ + return array_key_exists( $id, $this->logs ); + } + + /** + * @param Log $log + * + * @return bool + */ + public function hasLog( Log $log ){ + return array_key_exists( $log->getId(), $this->logs ); + } + + /** + * @return Log|null Log or null if there is no log + */ + public function getLatest() { + if( empty( $this->logs ) ) { + return null; + } + return $this->logs[ max( array_keys( $this->logs ) ) ]; + } + + /** + * @since 0.6 + * @return Log|null Log or null if there is no log + */ + public function getOldest() { + if( empty( $this->logs ) ) { + return null; + } + return $this->logs[ min( array_keys( $this->logs ) ) ]; + } + + /** + * @since 0.6 + * @return bool + */ + public function isEmpty() { + return empty( $this->logs ); + } + + /** + * @param int $id + * + * @throws RuntimeException + * @return Log + */ + public function get( $id ){ + if( $this->hasLogWithId( $id ) ){ + return $this->logs[$id]; + } + throw new RuntimeException( 'No such Log loaded in LogList object' ); + } + + /** + * @return Log[] + */ + public function toArray() { + return $this->logs; + } + + /** + * @link http://php.net/manual/en/jsonserializable.jsonserialize.php + */ + public function jsonSerialize() { + return $this->toArray(); + } + + /** + * @param array $json + * + * @return self + */ + public static function jsonDeserialize( $json ) { + $self = new LogList(); + foreach ( $json as $logJson ) { + $self->addLog( Log::jsonDeserialize( $logJson ) ); + } + return $self; + } +}
\ No newline at end of file diff --git a/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/NamespaceInfo.php b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/NamespaceInfo.php new file mode 100644 index 00000000..451ec972 --- /dev/null +++ b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/NamespaceInfo.php @@ -0,0 +1,131 @@ +<?php + +namespace Mediawiki\DataModel; + +/** + * Class representing metadata about a MediaWiki namespace + * + * @author gbirke + */ +class NamespaceInfo +{ + /** + * @var int + */ + private $id; + + /** + * @var string + */ + private $canonicalName; + + /** + * @var string + */ + private $localName; + + /** + * @var string + */ + private $caseHandling; + + /** + * @var string + */ + private $defaultContentModel; + + /** + * @var array + */ + private $aliases; + + /** + * NamespaceInfo constructor. + * @param int $id + * @param string $canonicalName + * @param string $localName + * @param string $caseHandling + * @param string $defaultContentModel + * @param array $aliases + * + * @throws InvalidArgumentException + */ + public function __construct( $id, $canonicalName, $localName, $caseHandling, $defaultContentModel = null, $aliases = [] ) + { + if( !is_int( $id ) ) { + throw new \InvalidArgumentException( '$id must be an integer' ); + } + if ( !is_string( $canonicalName ) ) { + throw new \InvalidArgumentException( '$canonicalName must be a string' ); + } + if ( !is_string( $localName ) ) { + throw new \InvalidArgumentException( '$localName must be a string' ); + } + if ( !is_string( $caseHandling ) ) { + throw new \InvalidArgumentException( '$caseHandling must be a string' ); + } + if ( !is_null( $defaultContentModel) && !is_string( $defaultContentModel ) ) { + throw new \InvalidArgumentException( '$canonicalName must be a string' ); + } + + if ( !is_array( $aliases ) ) { + throw new \InvalidArgumentException( '$aliases must be an array' ); + } + + $this->id = $id; + $this->canonicalName = $canonicalName; + $this->localName = $localName; + $this->caseHandling = $caseHandling; + $this->defaultContentModel = $defaultContentModel; + $this->aliases = $aliases; + } + + /** + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * @return string + */ + public function getCanonicalName() + { + return $this->canonicalName; + } + + /** + * @return string + */ + public function getLocalName() + { + return $this->localName; + } + + /** + * @return string + */ + public function getCaseHandling() + { + return $this->caseHandling; + } + + /** + * @return string + */ + public function getDefaultContentModel() + { + return $this->defaultContentModel; + } + + /** + * @return array + */ + public function getAliases() + { + return $this->aliases; + } + +}
\ No newline at end of file diff --git a/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Page.php b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Page.php new file mode 100644 index 00000000..c3951e85 --- /dev/null +++ b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Page.php @@ -0,0 +1,63 @@ +<?php + +namespace Mediawiki\DataModel; + +use InvalidArgumentException; + +class Page { + + /** + * @var Revisions + */ + private $revisions; + + /** + * @var PageIdentifier + */ + private $pageIdentifier; + + /** + * @param PageIdentifier $pageIdentifier + * @param Revisions|null $revisions + * + * @throws InvalidArgumentException + */ + public function __construct( PageIdentifier $pageIdentifier = null , Revisions $revisions = null ) { + if( is_null( $revisions ) ) { + $revisions = new Revisions(); + } + $this->revisions = $revisions; + $this->pageIdentifier = $pageIdentifier; + } + + /** + * @deprecated since 0.5 + * @return int + */ + public function getId() { + return $this->pageIdentifier->getId(); + } + + /** + * @return Revisions + */ + public function getRevisions() { + return $this->revisions; + } + + /** + * @deprecated since 0.5 + * @return Title + */ + public function getTitle() { + return $this->pageIdentifier->getTitle(); + } + + /** + * @return PageIdentifier + */ + public function getPageIdentifier() { + return $this->pageIdentifier; + } + +}
\ No newline at end of file diff --git a/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/PageIdentifier.php b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/PageIdentifier.php new file mode 100644 index 00000000..528e3c88 --- /dev/null +++ b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/PageIdentifier.php @@ -0,0 +1,85 @@ +<?php + +namespace Mediawiki\DataModel; + +use InvalidArgumentException; +use JsonSerializable; + +class PageIdentifier implements JsonSerializable { + + /** + * @var int|null + */ + private $id; + + /** + * @var Title|null + */ + private $title; + + /** + * @param Title|null $title + * @param int|null $id + * @throws InvalidArgumentException + */ + public function __construct( Title $title = null, $id = null ) { + if( !is_int( $id ) && !is_null( $id ) ) { + throw new InvalidArgumentException( '$id must be an int' ); + } + $this->title = $title; + $this->id = $id; + } + + /** + * @return int|null + */ + public function getId() { + return $this->id; + } + + /** + * @return Title|null + */ + public function getTitle() { + return $this->title; + } + + /** + * Does this object identify a page + * @return bool + */ + public function identifiesPage() { + if( is_null( $this->title ) && is_null( $this->id ) ) { + return false; + } + return true; + } + + /** + * @link http://php.net/manual/en/jsonserializable.jsonserialize.php + */ + public function jsonSerialize() { + $array = array(); + if ( $this->id !== null ) { + $array['id'] = $this->id; + } + if ( $this->title !== null ) { + $array['title'] = $this->title->jsonSerialize(); + } + return $array; + } + + /** + * @param array $array + * + * @returns self + */ + public static function jsonDeserialize( $array ) { + return new self( + isset( $array['title'] ) ? Title::jsonDeserialize( $array['title'] ) : null, + isset( $array['id'] ) ? $array['id'] : null + + ); + } +} +
\ No newline at end of file diff --git a/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Pages.php b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Pages.php new file mode 100644 index 00000000..b8c5614c --- /dev/null +++ b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Pages.php @@ -0,0 +1,99 @@ +<?php + +namespace Mediawiki\DataModel; + +use InvalidArgumentException; +use RuntimeException; + +/** + * Represents a collection or Page classes + * @author Addshore + */ +class Pages { + + /** + * @var Page[] + */ + private $pages; + + /** + * @param Page[] $pages + */ + public function __construct( $pages = array() ) { + $this->pages = array(); + $this->addPages( $pages ); + } + + /** + * @param Page[]|Pages $pages + * + * @throws InvalidArgumentException + */ + public function addPages( $pages ) { + if( !is_array( $pages ) && !$pages instanceof Pages ) { + throw new InvalidArgumentException( '$pages needs to either be an array or a Pages object' ); + } + if( $pages instanceof Pages ) { + $pages = $pages->toArray(); + } + foreach( $pages as $page ) { + $this->addPage( $page ); + } + } + + /** + * @param Page $page + */ + public function addPage( Page $page ) { + $this->pages[$page->getId()] = $page; + } + + /** + * @param int $id + * + * @return bool + */ + public function hasPageWithId( $id ){ + return array_key_exists( $id, $this->pages ); + } + + /** + * @param Page $page + * + * @return bool + */ + public function hasPage( Page $page ){ + return array_key_exists( $page->getId(), $this->pages ); + } + + /** + * @return Page|null Page or null if there is no page + */ + public function getLatest() { + if( empty( $this->pages ) ) { + return null; + } + return $this->pages[ max( array_keys( $this->pages ) ) ]; + } + + + /** + * @param int $pageid + * + * @throws RuntimeException + * @return Page + */ + public function get( $pageid ){ + if( $this->hasPageWithId( $pageid ) ){ + return $this->pages[$pageid]; + } + throw new RuntimeException( 'No such page loaded in Pages object' ); + } + + /** + * @return Page[] + */ + public function toArray() { + return $this->pages; + } +}
\ No newline at end of file diff --git a/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Redirect.php b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Redirect.php new file mode 100644 index 00000000..55b8b607 --- /dev/null +++ b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Redirect.php @@ -0,0 +1,53 @@ +<?php + +namespace Mediawiki\DataModel; + +use JsonSerializable; + +class Redirect implements JsonSerializable { + + private $from; + private $to; + + public function __construct( Title $from, Title $to ) { + $this->from = $from; + $this->to = $to; + } + + /** + * @return Title + */ + public function getFrom() { + return $this->from; + } + + /** + * @return Title + */ + public function getTo() { + return $this->to; + } + + /** + * @link http://php.net/manual/en/jsonserializable.jsonserialize.php + */ + public function jsonSerialize() { + return array( + 'from' => $this->from->jsonSerialize(), + 'to' => $this->to->jsonSerialize(), + ); + } + + /** + * @param array $json + * + * @return self + */ + public static function jsonDeserialize( $json ) { + return new self( + Title::jsonDeserialize( $json['from'] ), + Title::jsonDeserialize( $json['to'] ) + ); + } + +} diff --git a/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Revision.php b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Revision.php new file mode 100644 index 00000000..09afe63f --- /dev/null +++ b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Revision.php @@ -0,0 +1,106 @@ +<?php + +namespace Mediawiki\DataModel; + +/** + * Representation of a version of content + * @author Addshore + */ +class Revision { + + /** + * @var int Id of the revision + */ + private $id; + + /** + * @var PageIdentifier of the page for the revision + */ + private $pageIdentifier; + + /** + * @var Content + */ + private $content; + + /** + * @var EditInfo + */ + private $editInfo; + + /** + * @var null|string + */ + private $user; + + /** + * @var null|string + */ + private $timestamp; + + /** + * @param Content $content + * @param PageIdentifier|null $pageIdentifier + * @param int|null $revId + * @param EditInfo|null $editInfo + * @param string|null $user + * @param string|null $timestamp + */ + public function __construct( Content $content, PageIdentifier $pageIdentifier = null, $revId = null, EditInfo $editInfo = null, $user = null, $timestamp = null ) { + if( is_null( $editInfo ) ) { + $editInfo = new EditInfo(); + } + if( is_null( $pageIdentifier ) ) { + $pageIdentifier = new PageIdentifier(); + } + $this->content = $content; + $this->pageIdentifier = $pageIdentifier; + $this->id = $revId; + $this->editInfo = $editInfo; + $this->user = $user; + $this->timestamp = $timestamp; + } + + /** + * @return Content + */ + public function getContent() { + return $this->content; + } + + /** + * @return EditInfo + */ + public function getEditInfo() { + return $this->editInfo; + } + + /** + * @return int|null + */ + public function getId() { + return $this->id; + } + + /** + * @return PageIdentifier|null + */ + public function getPageIdentifier() { + return $this->pageIdentifier; + } + + /** + * @return null|string + */ + public function getUser() { + return $this->user; + } + + /** + * @return null|string + */ + public function getTimestamp() { + return $this->timestamp; + } + +}
\ No newline at end of file diff --git a/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Revisions.php b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Revisions.php new file mode 100644 index 00000000..c6d2f436 --- /dev/null +++ b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Revisions.php @@ -0,0 +1,102 @@ +<?php + +namespace Mediawiki\DataModel; + +use InvalidArgumentException; +use RuntimeException; + +/** + * Represents a collection or revisions + * @author Addshore + */ +class Revisions { + + /** + * @var Revision[] + */ + private $revisions; + + /** + * @param Revisions[] $revisions + */ + public function __construct( $revisions = array() ) { + $this->revisions = array(); + $this->addRevisions( $revisions ); + } + + /** + * @param Revision[]|Revisions $revisions + * + * @throws InvalidArgumentException + */ + public function addRevisions( $revisions ) { + if( !is_array( $revisions ) && !$revisions instanceof Revisions ) { + throw new InvalidArgumentException( '$revisions needs to either be an array or a Revisions object' ); + } + if( $revisions instanceof Revisions ) { + $revisions = $revisions->toArray(); + } + foreach( $revisions as $revision ) { + $this->addRevision( $revision ); + } + } + + /** + * @param Revision $revision + */ + public function addRevision( Revision $revision ) { + $this->revisions[$revision->getId()] = $revision; + } + + /** + * @param int $id + * + * @return bool + */ + public function hasRevisionWithId( $id ){ + return array_key_exists( $id, $this->revisions ); + } + + /** + * @param Revision $revision + * + * @return bool + */ + public function hasRevision( Revision $revision ){ + return array_key_exists( $revision->getId(), $this->revisions ); + } + + /** + * @return Revision|null Revision or null if there is no revision + */ + public function getLatest() { + if( empty( $this->revisions ) ) { + return null; + } + return $this->revisions[ max( array_keys( $this->revisions ) ) ]; + } + + /** + * @param int $revid + * + * @throws RuntimeException + * @throws InvalidArgumentException + * @return Revision + */ + public function get( $revid ){ + if( !is_int( $revid ) ) { + throw new InvalidArgumentException( '$revid needs to be an int' ); + } + if( $this->hasRevisionWithId( $revid ) ){ + return $this->revisions[$revid]; + } + throw new RuntimeException( 'No such revision loaded in Revisions object' ); + } + + /** + * @return Revision[] + */ + public function toArray() { + return $this->revisions; + } +}
\ No newline at end of file diff --git a/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Title.php b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Title.php new file mode 100644 index 00000000..1fb15138 --- /dev/null +++ b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Title.php @@ -0,0 +1,83 @@ +<?php + +namespace Mediawiki\DataModel; + +use InvalidArgumentException; +use JsonSerializable; + +/** + * @author Addshore + */ +class Title implements JsonSerializable { + + /** + * @var string + */ + private $title; + + /** + * @var int + */ + private $ns; + + /** + * @param string $title + * @param int $ns + * + * @throws InvalidArgumentException + */ + public function __construct( $title, $ns = 0 ) { + if( !is_string( $title ) ) { + throw new InvalidArgumentException( '$title must be a string' ); + } + if( !is_int( $ns ) ) { + throw new InvalidArgumentException( '$ns must be an int' ); + } + $this->title = $title; + $this->ns = $ns; + } + + /** + * @return int + * @since 0.1 + */ + public function getNs() { + return $this->ns; + } + + /** + * @return string + * @since 0.6 + */ + public function getText() { + return $this->title; + } + + /** + * @return string + * @deprecated in 0.6 use getText (makes things look cleaner) + */ + public function getTitle() { + return $this->getText(); + } + + /** + * @link http://php.net/manual/en/jsonserializable.jsonserialize.php + */ + public function jsonSerialize() { + return array( + 'title' => $this->title, + 'ns' => $this->ns, + ); + } + + /** + * @param array $json + * + * @return self + */ + public static function jsonDeserialize( $json ) { + return new self( $json['title'], $json['ns'] ); + } + +} diff --git a/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/User.php b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/User.php new file mode 100644 index 00000000..fca5ddf3 --- /dev/null +++ b/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/User.php @@ -0,0 +1,140 @@ +<?php + +namespace Mediawiki\DataModel; + +use InvalidArgumentException; + +/** + * Represents a mediawiki user + * @author Addshore + */ +class User { + + /** + * @var string + */ + private $name; + + /** + * @var int + */ + private $id; + + /** + * @var int + */ + private $editcount; + + /** + * @var string + */ + private $registration; + + /** + * @var array + */ + private $groups; + + /** + * @var array + */ + private $rights; + + /** + * @var string + */ + private $gender; + + /** + * @param string $name + * @param int $id + * @param int $editcount + * @param string $registration + * @param array[] $groups groups grouped by type. + * Keys to use are 'groups' and 'implicitgroups' as returned by the api. + * @param array $rights + * @param string $gender + * + * @throws InvalidArgumentException + */ + public function __construct( $name, $id, $editcount, $registration, $groups, $rights, $gender ) { + if( !is_string( $name ) || empty( $name ) ) { + throw new InvalidArgumentException( '$name must be a string and can not be empty' ); + } + if( !is_int( $id ) ) { + throw new InvalidArgumentException( '$id must be an int' ); + } + if( !is_int( $editcount ) ) { + throw new InvalidArgumentException( '$editcount must be an int' ); + } + if( !is_array( $groups ) || !array_key_exists( 'groups', $groups ) || !array_key_exists( 'implicitgroups', $groups ) ) { + throw new InvalidArgumentException( '$groups must be an array or arrays with keys "groups" and "implicitgroups"' ); + } + if( !is_array( $rights ) ) { + throw new InvalidArgumentException( '$rights must be an array' ); + } + if( !is_string( $gender ) ) { + throw new InvalidArgumentException( '$gender must be a string' ); + } + + $this->editcount = $editcount; + $this->gender = $gender; + $this->groups = $groups; + $this->id = $id; + $this->name = $name; + $this->registration = $registration; + $this->rights = $rights; + } + + /** + * @return int + */ + public function getEditcount() { + return $this->editcount; + } + + /** + * @return string + */ + public function getGender() { + return $this->gender; + } + + /** + * @param string $type 'groups' or 'implicitgroups' + * + * @return array + */ + public function getGroups( $type = 'groups' ) { + return $this->groups[$type]; + } + + /** + * @return int + */ + public function getId() { + return $this->id; + } + + /** + * @return string + */ + public function getName() { + return $this->name; + } + + /** + * @return string + */ + public function getRegistration() { + return $this->registration; + } + + /** + * @return array + */ + public function getRights() { + return $this->rights; + } + +} |