| Total Complexity | 5 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | class MediaUpdater extends Component |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * @var \app\models\Media |
||
| 23 | */ |
||
| 24 | public $media; |
||
| 25 | |||
| 26 | public function init() |
||
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 34 | public function details(Post $post): Media |
||
| 35 | { |
||
| 36 | $this->media->instagram_id = $post->id; |
||
| 37 | $this->media->shortcode = $post->shortcode; |
||
| 38 | $this->media->is_video = $post->isVideo; |
||
| 39 | $this->media->caption = $post->caption; |
||
| 40 | $this->media->taken_at = (new \DateTime('@' . $post->takenAt))->format('Y-m-d H:i:s'); |
||
| 41 | $this->media->likes = $post->likes; |
||
| 42 | $this->media->comments = $post->comments; |
||
| 43 | |||
| 44 | $this->saveModel($this->media); |
||
| 45 | |||
| 46 | return $this->media; |
||
| 47 | } |
||
| 48 | |||
| 49 | private function saveModel(ActiveRecord $model) |
||
| 56 | } |
||
| 57 | } |