1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace refill;
- class ratio
- {
- private $mCommitSucc;
- private $mCommitFail;
- private $mNotifySucc;
- private $mNotifyFail;
- public function __construct()
- {
- $this->mCommitSucc = 0;
- $this->mCommitFail = 0;
- $this->mNotifySucc = 0;
- $this->mNotifyFail = 0;
- }
- public function update(array $data)
- {
- $this->mCommitSucc = $data[0];
- $this->mCommitFail = $data[1];
- $this->mNotifySucc = $data[2];
- $this->mNotifyFail = $data[3];
- }
- public function commit_ratio()
- {
- $count = $this->mCommitSucc + $this->mCommitFail;
- if($count > 0) {
- return [true,$this->mCommitSucc / $count];
- } else {
- return [false,0];
- }
- }
- public function notify_ratio()
- {
- $count = $this->mNotifySucc + $this->mNotifyFail;
- if($count > 0) {
- return [true,$this->mCommitSucc / $count];
- } else {
- return [false,0];
- }
- }
- }
|