counter-factory.php
88 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WP_Social\Lib\Provider; |
| 4 | |
| 5 | use WP_Social\Lib\Provider\Counter\Comments_Counter; |
| 6 | use WP_Social\Lib\Provider\Counter\Dribbble_Counter; |
| 7 | use WP_Social\Lib\Provider\Counter\Facebook_Counter; |
| 8 | use WP_Social\Lib\Provider\Counter\Instagram_Counter; |
| 9 | use WP_Social\Lib\Provider\Counter\Tiktok_Counter; |
| 10 | use WP_Social\Lib\Provider\Counter\No_Provider_Counter; |
| 11 | use WP_Social\Lib\Provider\Counter\Pinterest_Counter; |
| 12 | use WP_Social\Lib\Provider\Counter\Posts_Counter; |
| 13 | use WP_Social\Lib\Provider\Counter\Twitter_Counter; |
| 14 | use WP_Social\Lib\Provider\Counter\Youtube_Counter; |
| 15 | |
| 16 | |
| 17 | class Counter_Factory { |
| 18 | |
| 19 | private $provider_type; |
| 20 | |
| 21 | public $factory; |
| 22 | |
| 23 | private $def_cache_time; |
| 24 | |
| 25 | |
| 26 | public function __construct($cache_time = 43200) { |
| 27 | |
| 28 | $this->def_cache_time = $cache_time; |
| 29 | } |
| 30 | |
| 31 | |
| 32 | public function make($type) { |
| 33 | |
| 34 | $this->provider_type = $type; |
| 35 | |
| 36 | switch($type) { |
| 37 | |
| 38 | case 'instagram' : |
| 39 | $this->factory = new Instagram_Counter(); |
| 40 | break; |
| 41 | |
| 42 | case 'tiktok' : |
| 43 | $this->factory = new Tiktok_Counter(); |
| 44 | break; |
| 45 | |
| 46 | // case 'mailchimp' : |
| 47 | // $this->factory = new Mailchimp_Counter(); |
| 48 | // break; |
| 49 | |
| 50 | case 'facebook' : |
| 51 | $this->factory = new Facebook_Counter(); |
| 52 | break; |
| 53 | |
| 54 | case 'twitter' : |
| 55 | $this->factory = new Twitter_Counter(); |
| 56 | break; |
| 57 | |
| 58 | case 'pinterest' : |
| 59 | $this->factory = new Pinterest_Counter(); |
| 60 | break; |
| 61 | |
| 62 | case 'dribbble' : |
| 63 | $this->factory = new Dribbble_Counter(); |
| 64 | break; |
| 65 | |
| 66 | case 'youtube' : |
| 67 | $this->factory = new Youtube_Counter(); |
| 68 | break; |
| 69 | |
| 70 | case 'comments' : |
| 71 | $this->factory = new Comments_Counter(); |
| 72 | break; |
| 73 | |
| 74 | case 'posts' : |
| 75 | $this->factory = new Posts_Counter(); |
| 76 | break; |
| 77 | |
| 78 | default: |
| 79 | $this->factory = new No_Provider_Counter(); |
| 80 | |
| 81 | } |
| 82 | |
| 83 | $this->factory->set_cache_time($this->def_cache_time); |
| 84 | |
| 85 | return $this->factory; |
| 86 | } |
| 87 | } |
| 88 |