-
Notifications
You must be signed in to change notification settings - Fork 736
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust naming and run linting for index-template-support
- Loading branch information
Showing
4 changed files
with
20 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
* Elastica index template object. | ||
* | ||
* @author Dmitry Balabka <[email protected]> | ||
* | ||
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html | ||
*/ | ||
class IndexTemplate | ||
{ | ||
|
@@ -15,14 +17,14 @@ class IndexTemplate | |
* | ||
* @var string Index pattern | ||
*/ | ||
protected $name = ''; | ||
protected $_name = ''; | ||
|
||
/** | ||
* Client object. | ||
* | ||
* @var \Elastica\Client Client object | ||
*/ | ||
protected $client = null; | ||
protected $_client = null; | ||
|
||
/** | ||
* Creates a new index template object. | ||
|
@@ -34,12 +36,12 @@ class IndexTemplate | |
*/ | ||
public function __construct(Client $client, $name) | ||
{ | ||
$this->client = $client; | ||
$this->_client = $client; | ||
|
||
if (!is_scalar($name)) { | ||
throw new InvalidException('Index template should be a scalar type'); | ||
} | ||
$this->name = (string) $name; | ||
$this->_name = (string) $name; | ||
} | ||
|
||
/** | ||
|
@@ -59,7 +61,7 @@ public function delete() | |
* | ||
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html | ||
* | ||
* @param array $args OPTIONAL Arguments to use | ||
* @param array $args OPTIONAL Arguments to use | ||
* | ||
* @return \Elastica\Response | ||
*/ | ||
|
@@ -88,7 +90,7 @@ public function exists() | |
*/ | ||
public function getName() | ||
{ | ||
return $this->name; | ||
return $this->_name; | ||
} | ||
|
||
/** | ||
|
@@ -98,7 +100,7 @@ public function getName() | |
*/ | ||
public function getClient() | ||
{ | ||
return $this->client; | ||
return $this->_client; | ||
} | ||
|
||
/** | ||
|
@@ -111,7 +113,7 @@ public function getClient() | |
*/ | ||
public function request($method, $data = array()) | ||
{ | ||
$path = '/_template/' . $this->getName(); | ||
$path = '/_template/'.$this->getName(); | ||
|
||
return $this->getClient()->request($path, $method, $data); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,15 +2,13 @@ | |
namespace Elastica\Test; | ||
|
||
use Elastica\Client; | ||
use Elastica\Index; | ||
use Elastica\IndexTemplate; | ||
use Elastica\Request; | ||
use Elastica\Response; | ||
use Elastica\Test\Base as BaseTest; | ||
use Elastica\Type; | ||
|
||
/** | ||
* IndexTemplate class tests | ||
* IndexTemplate class tests. | ||
* | ||
* @author Dmitry Balabka <[email protected]> | ||
*/ | ||
|
@@ -50,7 +48,7 @@ public function testDelete() | |
$clientMock = $this->getMock('\Elastica\Client', array('request')); | ||
$clientMock->expects($this->once()) | ||
->method('request') | ||
->with('/_template/' . $name, Request::DELETE, array(), array()) | ||
->with('/_template/'.$name, Request::DELETE, array(), array()) | ||
->willReturn($response); | ||
$indexTemplate = new IndexTemplate($clientMock, $name); | ||
$this->assertSame($response, $indexTemplate->delete()); | ||
|
@@ -68,7 +66,7 @@ public function testCreate() | |
$clientMock = $this->getMock('\Elastica\Client', array('request')); | ||
$clientMock->expects($this->once()) | ||
->method('request') | ||
->with('/_template/' . $name, Request::PUT, $args, array()) | ||
->with('/_template/'.$name, Request::PUT, $args, array()) | ||
->willReturn($response); | ||
$indexTemplate = new IndexTemplate($clientMock, $name); | ||
$this->assertSame($response, $indexTemplate->create($args)); | ||
|
@@ -86,7 +84,7 @@ public function testExists() | |
$clientMock = $this->getMock('\Elastica\Client', array('request')); | ||
$clientMock->expects($this->once()) | ||
->method('request') | ||
->with('/_template/' . $name, Request::HEAD, array(), array()) | ||
->with('/_template/'.$name, Request::HEAD, array(), array()) | ||
->willReturn($response); | ||
$indexTemplate = new IndexTemplate($clientMock, $name); | ||
$this->assertTrue($indexTemplate->exists()); | ||
|
@@ -100,7 +98,7 @@ public function testCreateTemplate() | |
$template = array( | ||
'template' => 'te*', | ||
'settings' => array( | ||
'number_of_shards' => 1 | ||
'number_of_shards' => 1, | ||
), | ||
); | ||
$name = 'index_template1'; | ||
|