Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
result.php
1<?php
2
3namespace Bitrix\Bizproc;
4
6{
7 public static function createFromErrorCode(string $code, $customData = null): self
8 {
9 return static::createError(Error::fromCode($code, $customData));
10 }
11
12 public static function createError(Error $error): static
13 {
14 $res = new static();
15 $res->addError($error);
16
17 return $res;
18 }
19
20 public static function createOk(?array $data = null): static
21 {
22 $res = new static();
23
24 if (is_array($data))
25 {
26 $res->setData($data);
27 }
28
29 return $res;
30 }
31
32 public function map(callable $callback): self
33 {
34 if ($this->isSuccess())
35 {
36 return $callback($this->getData());
37 }
38
39 return $this;
40 }
41
45 public function getErrors(): array
46 {
47 return $this->errors->toArray();
48 }
49}
static fromCode(string $code, $customData=null)
Definition error.php:13
static createFromErrorCode(string $code, $customData=null)
Definition result.php:7
static createError(Error $error)
Definition result.php:12
static createOk(?array $data=null)
Definition result.php:20
map(callable $callback)
Definition result.php:32