| @@ -5,31 +5,36 @@ | ||
| 5 | 5 | use FluentForm\App\Services\FormBuilder\ShortCodeParser; |
| 6 | 6 | |
| 7 | 7 | class NotificationParser |
| 8 | 8 | { |
| 9 | - protected static $cache = null; | |
| 9 | + protected static $cache = null; | |
| 10 | 10 | |
| 11 | - /** | |
| 12 | - * Parse Norifications | |
| 13 | - * @param array $notifications | |
| 14 | - * @param int $insertId | |
| 15 | - * @param array $data | |
| 11 | + /** | |
| 12 | + * Parse Norifications | |
| 13 | + * | |
| 14 | + * @param array $notifications | |
| 15 | + * @param int $insertId | |
| 16 | + * @param array $data | |
| 16 | 17 | * @param object $form |
| 17 | - * @return bool $cache | |
| 18 | - */ | |
| 19 | - public static function parse($notifications, $insertId, $data, $form, $cache = true) | |
| 18 | + * | |
| 19 | + * @return bool $cache | |
| 20 | + */ | |
| 21 | + public static function parse($notifications, $insertId, $data, $form, $cache = true) | |
| 20 | 22 | { |
| 21 | - if ($cache && !is_null(static::$cache)) { | |
| 22 | - return static::$cache; | |
| 23 | - } | |
| 23 | + if ($cache && ! is_null(static::$cache)) { | |
| 24 | + return static::$cache; | |
| 25 | + } | |
| 24 | 26 | |
| 25 | 27 | foreach ($notifications as &$notification) { |
| 26 | 28 | static::setRecepient($notification, $data); |
| 27 | 29 | |
| 28 | - $notification = ShortCodeParser::parse( | |
| 29 | - $notification, $insertId, $data, $form | |
| 30 | - ); | |
| 31 | - } | |
| 30 | + $notification = ShortCodeParser::parse( | |
| 31 | + $notification, | |
| 32 | + $insertId, | |
| 33 | + $data, | |
| 34 | + $form | |
| 35 | + ); | |
| 36 | + } | |
| 32 | 37 | |
| 33 | 38 | return $cache ? (static::$cache = $notifications) : $notifications; |
| 34 | 39 | } |
| 35 | 40 | |
| @@ -34,9 +39,9 @@ | ||
| 34 | 39 | } |
| 35 | 40 | |
| 36 | 41 | protected static function setRecepient(&$notification, $data) |
| 37 | 42 | { |
| 38 | - if (isset($notification['sendTo']) && $notification['sendTo']['type'] == 'field') { | |
| 43 | + if (isset($notification['sendTo']) && 'field' == $notification['sendTo']['type']) { | |
| 39 | 44 | $notification['sendTo']['email'] = $data[$notification['sendTo']['field']]; |
| 40 | 45 | } |
| 41 | 46 | } |
| 42 | 47 | } |