|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Gitlab\Model; |
| 4 | + |
| 5 | +use Gitlab\Client; |
| 6 | + |
| 7 | +/** |
| 8 | + * Class Wiki |
| 9 | + * |
| 10 | + * @property-read string $slug |
| 11 | + * @property-read string $title |
| 12 | + * @property-read string $format |
| 13 | + * @property-read string $content |
| 14 | + * @property-read Project $project |
| 15 | + */ |
| 16 | +class Wiki extends AbstractModel |
| 17 | +{ |
| 18 | + /** |
| 19 | + * @var array |
| 20 | + */ |
| 21 | + protected static $properties = array( |
| 22 | + "slug", |
| 23 | + "title", |
| 24 | + "format", |
| 25 | + "content", |
| 26 | + ); |
| 27 | + |
| 28 | + /** |
| 29 | + * @param Client $client |
| 30 | + * @param Project $project |
| 31 | + * @param array $data |
| 32 | + * @return Wiki |
| 33 | + */ |
| 34 | + public static function fromArray(Client $client, Project $project, array $data) |
| 35 | + { |
| 36 | + $wiki = new static($project, $data['id'], $client); |
| 37 | + |
| 38 | + return $wiki->hydrate($data); |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + * @param Project $project |
| 43 | + * @param int $id |
| 44 | + * @param Client $client |
| 45 | + */ |
| 46 | + public function __construct(Project $project, $id = null, Client $client = null) |
| 47 | + { |
| 48 | + $this->setClient($client); |
| 49 | + $this->setData('project', $project); |
| 50 | + $this->setData('id', $id); |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * @return Wiki |
| 55 | + */ |
| 56 | + public function show() |
| 57 | + { |
| 58 | + $data = $this->client->wiki()->show($this->project->id, $this->id); |
| 59 | + |
| 60 | + return static::fromArray($this->getClient(), $this->project, $data); |
| 61 | + } |
| 62 | + |
| 63 | + /** |
| 64 | + * @param array $params |
| 65 | + * @return Schedule |
| 66 | + */ |
| 67 | + public function update(array $params) |
| 68 | + { |
| 69 | + $data = $this->client->wiki()->update($this->project->id, $this->id, $params); |
| 70 | + |
| 71 | + return static::fromArray($this->getClient(), $this->project, $data); |
| 72 | + } |
| 73 | +} |
0 commit comments