| Total Complexity | 11 |
| Total Lines | 56 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class Translation implements AsyncBrokerInterface |
||
| 9 | { |
||
| 10 | protected $locales = []; |
||
| 11 | protected $words = []; |
||
| 12 | |||
| 13 | public function __construct(VocabTerm $vocab = null) |
||
| 14 | { |
||
| 15 | $this->locales = [ |
||
| 16 | app()->getLocale(), |
||
|
|
|||
| 17 | config('app.locale'), |
||
| 18 | config('app.fallback_locale'), |
||
| 19 | config('app.faker_locale'), |
||
| 20 | ]; |
||
| 21 | $this->words = $vocab ? [$vocab->id] : $this->words; |
||
| 22 | } |
||
| 23 | |||
| 24 | public function targetLocales($locales = []) |
||
| 25 | { |
||
| 26 | $this->locales = array_unique( |
||
| 27 | array_merge( |
||
| 28 | $this->locales, |
||
| 29 | $locales |
||
| 30 | ) |
||
| 31 | ); |
||
| 32 | |||
| 33 | return $this; |
||
| 34 | } |
||
| 35 | |||
| 36 | public function words($words = null) |
||
| 42 | } |
||
| 43 | |||
| 44 | public function handle() |
||
| 45 | { |
||
| 46 | foreach ($this->words as $word) { |
||
| 47 | $this->translation(VocabTerm::find($word)); |
||
| 48 | } |
||
| 49 | } |
||
| 50 | |||
| 51 | private function translation(VocabTerm $word) |
||
| 64 | } |
||
| 65 | } |
||
| 66 |