@@ -96,14 +96,20 @@ public function isTracking()
9696	 */ 
9797	public  function  update ($ status$ resultnull )
9898	{
99+ 		$ statusint ) $ status
100+ 
99101		if (!$ this isTracking ()) {
100102			return ;
101103		}
102104
105+ 		if ($ statusself ::STATUS_WAITING  || $ statusself ::STATUS_COMPLETE ) {
106+ 			return ;
107+ 		}
108+ 
103109		$ statusPacketarray (
104110			'status '   => $ status
105111			'updated '  => time (),
106- 			'started '  => $ this getValue ('started ' ),
112+ 			'started '  => $ this fetch ('started ' ),
107113			'result '   => $ result
108114		);
109115		Resque::redis ()->set ((string )$ this json_encode ($ statusPacket
@@ -115,23 +121,14 @@ public function update($status, $result = null)
115121	}
116122
117123	/** 
118- 	 * Fetch a value from  the status packet  for the job being monitored. 
124+ 	 * Fetch the status for the job being monitored. 
119125	 * 
120- 	 * @return mixed False if the status is not being monitored, otherwise the 
121- 	 *  requested value from  the status packet . 
126+ 	 * @return mixed False if the status is not being monitored, otherwise the status  
127+ 	 * 	as an integer, based on  the Resque_Job_Status constants . 
122128	 */ 
123- 	protected  function  getValue ( $ value  =  null )
129+ 	public  function  get ( )
124130	{
125- 		if (!$ this isTracking ()) {
126- 			return  false ;
127- 		}
128- 
129- 		$ statusPacketjson_decode (Resque::redis ()->get ((string )$ this true );
130- 		if (!$ statusPacket
131- 			return  false ;
132- 		}
133- 
134- 		return  empty ($ value$ statusPacket$ statusPacket$ value
131+ 		return  $ this status ();
135132	}
136133
137134	/** 
@@ -140,20 +137,42 @@ protected function getValue($value = null)
140137	 * @return mixed False if the status is not being monitored, otherwise the status 
141138	 * 	as an integer, based on the Resque_Job_Status constants. 
142139	 */ 
143- 	public  function  get ()
140+ 	public  function  status ()
144141	{
145- 		return  $ this getValue ('status ' );
142+ 		return  $ this fetch ('status ' );
146143	}
147144
145+ 	/** 
146+  	 * Fetch the last update timestamp of the job being monitored. 
147+  	 * 
148+  	 * @return mixed False if the job is not being monitored, otherwise the 
149+ 	 *  update timestamp. 
150+  	 */ 
151+ 	public  function  updated ()
152+ 	{
153+ 		return  $ this fetch ('updated ' );
154+  	}
155+ 
156+ 	/** 
157+  	 * Fetch the start timestamp of the job being monitored. 
158+  	 * 
159+  	 * @return mixed False if the job is not being monitored, otherwise the 
160+ 	 *  start timestamp. 
161+  	 */ 
162+ 	public  function  started ()
163+ 	{
164+ 		return  $ this fetch ('started ' );
165+  	}
166+ 
148167	/** 
149168 	 * Fetch the result of the job being monitored. 
150169 	 * 
151170 	 * @return mixed False if the job is not being monitored, otherwise the result 
152171 	 * 	as mixed 
153172 	 */ 
154- 	public  function  getResult ()
173+ 	public  function  result ()
155174	{
156- 		return  $ this getValue ('result ' );
175+ 		return  $ this fetch ('result ' );
157176 	}
158177
159178	/** 
@@ -173,4 +192,33 @@ public function __toString()
173192	{
174193		return  'job: '  . $ this prefix  . $ this id  . ':status ' ;
175194	}
195+ 
196+ 	/** 
197+ 	* Fetch a value from the status packet for the job being monitored. 
198+ 	* 
199+ 	* @return mixed False if the status is not being monitored, otherwise the 
200+ 	*  requested value from the status packet. 
201+ 	*/ 
202+ 	protected  function  fetch ($ valuenull )
203+ 	{
204+ 		if (!$ this isTracking ()) {
205+ 			return  false ;
206+ 		}
207+ 
208+ 		$ statusPacketjson_decode (Resque::redis ()->get ((string )$ this true );
209+ 		if (!$ statusPacket
210+ 			return  false ;
211+ 		}
212+ 
213+ 		if (empty ($ value
214+ 			return  $ statusPacket
215+ 		} else  {
216+ 			if (isset ($ statusPacket$ value
217+ 				return  $ statusPacket$ value
218+ 			} else  {
219+ 				return  null ;
220+ 			}
221+ 		}
222+ 
223+ 	}
176224}
0 commit comments