1 | <?php namespace AwsHelper; |
||
6 | class SqsHelper |
||
7 | { |
||
8 | |||
9 | protected $sqs; |
||
10 | protected $adapter; |
||
11 | protected $queue_url; |
||
12 | protected $region; |
||
13 | |||
14 | public function __construct(AwsHelper $adapter, $queue_url, $region) |
||
21 | |||
22 | public function connect() |
||
26 | |||
27 | public function setQueueUrl($queue_url) |
||
31 | |||
32 | /* For when you want to stop the listener from running */ |
||
33 | public function stop() |
||
37 | |||
38 | /* Begin listening for messages from the SQS queue. |
||
39 | @param $num_msg Dictates how many messages you wish to process at a time |
||
40 | */ |
||
41 | public function listen($num_msg = 1) |
||
70 | |||
71 | /* Throws a message off the queue. I.E. It's been processed successfully |
||
72 | @params $message Feed it the message object you recieved from the listen method |
||
73 | */ |
||
74 | public function remove(SqsMessage $message) |
||
82 | |||
83 | /* Pushes something to the SQS service |
||
84 | @params $data The data of your message. |
||
85 | @params $attributes Any optional meta data attributes you wish to feed through |
||
86 | */ |
||
87 | public function push($data, $attributes = []) |
||
95 | |||
96 | /** |
||
97 | * Get a list of queue attributes |
||
98 | * @param array $attributes An array of queue attribute names |
||
99 | * @return array An array of specified queue attributes with keys as attribute names |
||
100 | */ |
||
101 | public function getQueueAttributes($attributes) |
||
112 | |||
113 | /** |
||
114 | * Shorthand function to get a single queue attribute |
||
115 | * @param string $attribute A Queue attribute |
||
116 | * @return mixed String data of the specified queue attribute or null |
||
117 | */ |
||
118 | public function getQueueAttribute($attribute) |
||
123 | } |
||
124 | |||
148 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: