Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Demonstration of Processor))
- */
- class SomeClass
- {
- /** @type string[] */
- private $allowedParam2Values = ['first', 'second', 'third'];
- /**
- * Some first processor
- *
- * @type int $id
- * @type string $param2
- * @type SomeInterface $param3
- */
- public function someProcessor1($id, $param2, SomeInterface $param3)
- {
- if (!is_int($id)) {
- throw new \InvalidArgumentException('Param id must be int');
- }
- if ($id < 0) {
- throw new \InvalidArgumentException('Param id must be more than 0');
- }
- if (!is_string($param2)) {
- throw new \InvalidArgumentException('Param param2 must be int');
- }
- if (!in_array($param2, $this->allowedParam2Values)) {
- throw new \InvalidArgumentException('Param param2 out of range');
- }
- // Some business logic here
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement