Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
9 / 9
TagConfigSender
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
9 / 9
 prepare
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 sync
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 localSync
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
5 / 5
1<?php
2
3namespace Qmp\Laravel\Tracker\Services\DeployData\Senders;
4
5class TagConfigSender extends AbstractSender
6{
7
8    protected $collection = 'tag_config';
9
10    /**
11     * Preapre data
12     *
13     * @param [type] $data
14     * @return self
15     */
16    protected function prepare($data)
17    {
18        $this->data = array_merge(['hash' => $data['hash']], $data['tracker']);
19        return $this;
20    }
21
22    /**
23     * Save to distant tracker
24     *
25     * @param array $data
26     * @return void
27     */
28    protected function sync()
29    {
30        $this->mongo->collection($this->collection)->updateOne(['hash' => $this->data['hash']], ['$set' => $this->data], ['upsert' => true]);
31    }
32
33    /**
34     * Save to local tracker
35     *
36     * @return void
37     */
38    protected function localSync()
39    {
40        $this->localMongo
41            ->collection($this->collection)
42            ->where('hash', $this->data['hash'])
43            ->update($this->data, ['upsert' => true]);
44    }
45}