AbstractNodesEndpoint.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Elasticsearch\Endpoints\Cluster\Nodes;
  3. use Elasticsearch\Common\Exceptions\InvalidArgumentException;
  4. use Elasticsearch\Endpoints\AbstractEndpoint;
  5. /**
  6. * Class AbstractNodesEndpoint
  7. *
  8. * @category Elasticsearch
  9. * @package Elasticsearch\Endpoints\Cluster\Nodes
  10. * @author Zachary Tong <zach@elastic.co>
  11. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
  12. * @link http://elastic.co
  13. */
  14. abstract class AbstractNodesEndpoint extends AbstractEndpoint
  15. {
  16. /** @var string A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you&#039;re connecting to, leave empty to get information from all nodes */
  17. protected $nodeID;
  18. /**
  19. * @param $nodeID
  20. *
  21. * @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException
  22. *
  23. * @return $this
  24. */
  25. public function setNodeID($nodeID)
  26. {
  27. if (isset($nodeID) !== true) {
  28. return $this;
  29. }
  30. if (!(is_array($nodeID) === true || is_string($nodeID) === true)) {
  31. throw new InvalidArgumentException("invalid node_id");
  32. }
  33. if (is_array($nodeID) === true) {
  34. $nodeID = implode(',', $nodeID);
  35. }
  36. $this->nodeID = $nodeID;
  37. return $this;
  38. }
  39. }