Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added typeCode query param #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ PHP API "КЛАДР в облаке"
* *OneString* - выполнить поиск по всему адресу (одной строкой), при включении этой опции результат нельзя получить в виде объектов КЛАДР, только в виде ассоциативного массива
* *WithParent* - получить объекты вместе с родителями (если true у объекта заполняется свойство Parent)
* *Limit* - ограничение количества возвращаемых объектов
* *TypeCode* - тип объектов для выдачи:
- 1 — города
- 2 — поселки
- 4 — деревни
Битовые комбинации, например, 3 ( 1 | 2 ) — города и поселки



Expand Down
12 changes: 12 additions & 0 deletions kladr.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ class Query
private $withParent;
private $limit;

private $typeCode;

public function __construct()
{
$this->parentType = NULL;
Expand Down Expand Up @@ -264,6 +266,8 @@ public function __get($name)
return $this->withParent;
case 'Limit':
return $this->limit;
case 'TypeCode':
return $this->typeCode;
default:
NULL;
}
Expand Down Expand Up @@ -295,6 +299,9 @@ public function __set($name, $value)
break;
case 'Limit':
$this->limit = $value;
break;
case 'TypeCode':
$this->typeCode = $value;
break;
}
}
Expand Down Expand Up @@ -337,6 +344,11 @@ public function __toString()
$string .= 'limit=' . $this->limit;
}

if ($this->typeCode) {
if (! empty($string)) $string .= '&';
$string .= 'typeCode=' . $this->typeCode;
}

return $string;
}
}