Peer.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <?php
  2. namespace Transmission\Model;
  3. /**
  4. * @author Ramon Kleiss <ramon@cubilon.nl>
  5. */
  6. class Peer extends AbstractModel
  7. {
  8. /**
  9. * @var string
  10. */
  11. protected $address;
  12. /**
  13. * @var integer
  14. */
  15. protected $port;
  16. /**
  17. * @var string
  18. */
  19. protected $clientName;
  20. /**
  21. * @var boolean
  22. */
  23. protected $clientChoked;
  24. /**
  25. * @var boolean
  26. */
  27. protected $clientInterested;
  28. /**
  29. * @var boolean
  30. */
  31. protected $downloading;
  32. /**
  33. * @var boolean
  34. */
  35. protected $encrypted;
  36. /**
  37. * @var boolean
  38. */
  39. protected $incoming;
  40. /**
  41. * @var boolean
  42. */
  43. protected $uploading;
  44. /**
  45. * @var boolean
  46. */
  47. protected $utp;
  48. /**
  49. * @var boolean
  50. */
  51. protected $peerChoked;
  52. /**
  53. * @var boolean
  54. */
  55. protected $peerInterested;
  56. /**
  57. * @var double
  58. */
  59. protected $progress;
  60. /**
  61. * @var integer
  62. */
  63. protected $uploadRate;
  64. /**
  65. * @var integer
  66. */
  67. protected $downloadRate;
  68. /**
  69. * @param string $address
  70. */
  71. public function setAddress($address)
  72. {
  73. $this->address = (string) $address;
  74. }
  75. /**
  76. * @return string
  77. */
  78. public function getAddress()
  79. {
  80. return $this->address;
  81. }
  82. /**
  83. * @param integer $port
  84. */
  85. public function setPort($port)
  86. {
  87. $this->port = (integer) $port;
  88. }
  89. /**
  90. * @return integer
  91. */
  92. public function getPort()
  93. {
  94. return $this->port;
  95. }
  96. /**
  97. * @param string $clientName
  98. */
  99. public function setClientName($clientName)
  100. {
  101. $this->clientName = (string) $clientName;
  102. }
  103. /**
  104. * @return string
  105. */
  106. public function getClientName()
  107. {
  108. return $this->clientName;
  109. }
  110. /**
  111. * @param boolean $choked
  112. */
  113. public function setClientChoked($choked)
  114. {
  115. $this->clientChoked = (boolean) $choked;
  116. }
  117. /**
  118. * @return boolean
  119. */
  120. public function isClientChoked()
  121. {
  122. return $this->clientChoked;
  123. }
  124. /**
  125. * @param boolean $interested
  126. */
  127. public function setClientInterested($interested)
  128. {
  129. $this->clientInterested = (boolean) $interested;
  130. }
  131. /**
  132. * @return boolean
  133. */
  134. public function isClientInterested()
  135. {
  136. return $this->clientInterested;
  137. }
  138. /**
  139. * @param boolean $downloading
  140. */
  141. public function setDownloading($downloading)
  142. {
  143. $this->downloading = (boolean) $downloading;
  144. }
  145. /**
  146. * @return boolean
  147. */
  148. public function isDownloading()
  149. {
  150. return $this->downloading;
  151. }
  152. /**
  153. * @param boolean $encrypted
  154. */
  155. public function setEncrypted($encrypted)
  156. {
  157. $this->encrypted = (boolean) $encrypted;
  158. }
  159. /**
  160. * @return boolean
  161. */
  162. public function isEncrypted()
  163. {
  164. return $this->encrypted;
  165. }
  166. /**
  167. * @param boolean $incoming
  168. */
  169. public function setIncoming($incoming)
  170. {
  171. $this->incoming = (boolean) $incoming;
  172. }
  173. /**
  174. * @return boolean
  175. */
  176. public function isIncoming()
  177. {
  178. return $this->incoming;
  179. }
  180. /**
  181. * @param boolean $uploading
  182. */
  183. public function setUploading($uploading)
  184. {
  185. $this->uploading = (boolean) $uploading;
  186. }
  187. /**
  188. * @return boolean
  189. */
  190. public function isUploading()
  191. {
  192. return $this->uploading;
  193. }
  194. /**
  195. * @param boolean $utp
  196. */
  197. public function setUtp($utp)
  198. {
  199. $this->utp = (boolean) $utp;
  200. }
  201. /**
  202. * @return boolean
  203. */
  204. public function isUtp()
  205. {
  206. return $this->utp;
  207. }
  208. /**
  209. * @param boolean $choked
  210. */
  211. public function setPeerChoked($choked)
  212. {
  213. $this->peerChoked = (boolean) $choked;
  214. }
  215. /**
  216. * @return boolean
  217. */
  218. public function isPeerChoked()
  219. {
  220. return $this->peerChoked;
  221. }
  222. /**
  223. * @param boolean $interested
  224. */
  225. public function setPeerInterested($interested)
  226. {
  227. $this->peerInterested = (boolean) $interested;
  228. }
  229. /**
  230. * @return boolean
  231. */
  232. public function isPeerInterested()
  233. {
  234. return $this->peerInterested;
  235. }
  236. /**
  237. * @param double $progress
  238. */
  239. public function setProgress($progress)
  240. {
  241. $this->progress = (double) $progress;
  242. }
  243. /**
  244. * @return double
  245. */
  246. public function getProgress()
  247. {
  248. return $this->progress;
  249. }
  250. /**
  251. * @param integer $rate
  252. */
  253. public function setUploadRate($rate)
  254. {
  255. $this->uploadRate = (integer) $rate;
  256. }
  257. /**
  258. * @return integer
  259. */
  260. public function getUploadRate()
  261. {
  262. return $this->uploadRate;
  263. }
  264. /**
  265. * @param integer $rate
  266. */
  267. public function setDownloadRate($rate)
  268. {
  269. $this->downloadRate = (integer) $rate;
  270. }
  271. /**
  272. * @return integer
  273. */
  274. public function getDownloadRate()
  275. {
  276. return $this->downloadRate;
  277. }
  278. /**
  279. * {@inheritDoc}
  280. */
  281. public static function getMapping()
  282. {
  283. return array(
  284. 'address' => 'address',
  285. 'port' => 'port',
  286. 'clientName' => 'clientName',
  287. 'clientIsChoked' => 'clientChoked',
  288. 'clientIsInterested' => 'clientInterested',
  289. 'isDownloadingFrom' => 'downloading',
  290. 'isEncrypted' => 'encrypted',
  291. 'isIncoming' => 'incoming',
  292. 'isUploadingTo' => 'uploading',
  293. 'isUTP' => 'utp',
  294. 'peerIsChoked' => 'peerChoked',
  295. 'peerIsInterested' => 'peerInterested',
  296. 'progress' => 'progress',
  297. 'rateToClient' => 'uploadRate',
  298. 'rateFromClient' => 'downloadRate'
  299. );
  300. }
  301. }