Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Added support for displayName property in the resources methods #153

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/Method.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ class Method implements ArrayInstantiationInterface, MessageSchemaInterface
*/
private $type;

/**
* The display name (optional)
*
* @see http://raml.org/spec.html#displayname
*
* @var string|null
*/
private $displayName;

/**
* The description of the method (optional)
*
Expand Down Expand Up @@ -149,6 +158,10 @@ public static function createFromArray($method, array $data = [], ApiDefinition
}
}

if (isset($data['displayName'])) {
$method->setDisplayName($data['displayName']);
}

if (isset($data['description'])) {
$method->setDescription($data['description']);
}
Expand Down Expand Up @@ -243,6 +256,28 @@ public function setDescription($description)

// --

/**
* Get the display name
*
* @return string|null
*/
public function getDisplayName()
{
return $this->displayName;
}

/**
* Set the display name
*
* @param string|null $displayName
*/
public function setDisplayName($displayName)
{
$this->displayName = $displayName;
}

// --

/**
* Get the base uri parameters
*
Expand Down
14 changes: 14 additions & 0 deletions tests/MethodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ public function shouldGetTheDescriptionIfPassedInTheDataArray()
$this->assertNull($method->getDescription());
}

/**
* @test
*/
public function shouldGetTheDisplayNameIfPassedInTheDataArray()
{
$apiDefinition = new ApiDefinition('The title');

$method = Method::createFromArray('get', ['displayName' => 'A dummy name'], $apiDefinition);
$this->assertSame('A dummy name', $method->getDisplayName());

$method = Method::createFromArray('get', [], $apiDefinition);
$this->assertNull($method->getDisplayName());
}

/**
* @test
*/
Expand Down