Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
35.00% covered (danger)
35.00%
7 / 20
87.50% covered (warning)
87.50%
7 / 8
CRAP
0.00% covered (danger)
0.00%
0 / 1
TranslateArticleJob
35.00% covered (danger)
35.00%
7 / 20
87.50% covered (warning)
87.50%
7 / 8
25.58
0.00% covered (danger)
0.00%
0 / 1
 getJobType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getTableAlias
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getRequiredArguments
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getDisplayNameArgument
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getEntityTypeName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getFieldsForTranslation
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
2
 getHtmlFields
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 useHtmlFormat
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2declare(strict_types=1);
3
4namespace App\Job;
5
6use Cake\Datasource\EntityInterface;
7
8/**
9 * TranslateArticleJob Class
10 *
11 * Job for translating article content using the Google Translate API.
12 */
13class TranslateArticleJob extends AbstractTranslateJob
14{
15    /**
16     * @inheritDoc
17     */
18    protected static function getJobType(): string
19    {
20        return 'article translation';
21    }
22
23    /**
24     * @inheritDoc
25     */
26    protected function getTableAlias(): string
27    {
28        return 'Articles';
29    }
30
31    /**
32     * @inheritDoc
33     */
34    protected function getRequiredArguments(): array
35    {
36        return ['id', 'title'];
37    }
38
39    /**
40     * @inheritDoc
41     */
42    protected function getDisplayNameArgument(): string
43    {
44        return 'title';
45    }
46
47    /**
48     * @inheritDoc
49     */
50    protected function getEntityTypeName(): string
51    {
52        return 'Article';
53    }
54
55    /**
56     * @inheritDoc
57     */
58    protected function getFieldsForTranslation(EntityInterface $entity): array
59    {
60        return [
61            'title' => (string)$entity->title,
62            'lede' => (string)$entity->lede,
63            'body' => (string)$entity->body,
64            'summary' => (string)$entity->summary,
65            'meta_title' => (string)$entity->meta_title,
66            'meta_description' => (string)$entity->meta_description,
67            'meta_keywords' => (string)$entity->meta_keywords,
68            'facebook_description' => (string)$entity->facebook_description,
69            'linkedin_description' => (string)$entity->linkedin_description,
70            'instagram_description' => (string)$entity->instagram_description,
71            'twitter_description' => (string)$entity->twitter_description,
72        ];
73    }
74
75    /**
76     * @inheritDoc
77     */
78    protected function getHtmlFields(): array
79    {
80        return ['body'];
81    }
82
83    /**
84     * @inheritDoc
85     */
86    protected function useHtmlFormat(): bool
87    {
88        return true;
89    }
90}