Skip to content

Commit 5af0b6c

Browse files
authored
Merge pull request #11 from Astrotomic/fix-scrutinizer
Fix scrutinizer
2 parents 7ffe3d7 + 86ae4a7 commit 5af0b6c

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

.codeclimate.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,7 @@ plugins:
3838
enabled: false
3939
Design/TooManyPublicMethods:
4040
enabled: false
41+
CyclomaticComplexity:
42+
enabled: false
4143
phan:
4244
enabled: false

.scrutinizer.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ build:
99
before:
1010
- mysql -e 'create database translatable_test;'
1111
- echo "CREATE USER 'homestead'@'localhost' IDENTIFIED BY 'secret'; \n GRANT ALL PRIVILEGES ON * . * TO 'homestead'@'localhost'; \nFLUSH PRIVILEGES; \n" | mysql -u root
12-
tests:
13-
override:
14-
- command: echo 1
12+
nodes:
13+
analysis:
14+
tests:
15+
override:
16+
- php-scrutinizer-run
1517

1618
tools:
1719
external_code_coverage:

src/Translatable/Translatable.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ public function getTranslation(?string $locale = null, bool $withFallback = null
6363
if ($translation = $this->getTranslationByLocaleKey($fallbackLocale)) {
6464
return $translation;
6565
}
66-
if ($fallbackLocale !== $configFallbackLocale && $translation = $this->getTranslationByLocaleKey($configFallbackLocale)) {
66+
if (
67+
is_string($configFallbackLocale)
68+
&& $fallbackLocale !== $configFallbackLocale
69+
&& $translation = $this->getTranslationByLocaleKey($configFallbackLocale)
70+
) {
6771
return $translation;
6872
}
6973
}
@@ -306,7 +310,7 @@ protected function saveTranslations(): bool
306310

307311
public function replicateWithTranslations(array $except = null): Model
308312
{
309-
$newInstance = parent::replicate($except);
313+
$newInstance = $this->replicate($except);
310314

311315
unset($newInstance->translations);
312316
foreach ($this->translations as $translation) {
@@ -328,6 +332,8 @@ protected function isTranslationDirty(Model $translation): bool
328332
public function getNewTranslation(string $locale): Model
329333
{
330334
$modelName = $this->getTranslationModelName();
335+
336+
/** @var Model $translation */
331337
$translation = new $modelName();
332338
$translation->setAttribute($this->getLocaleKey(), $locale);
333339
$this->translations->add($translation);

0 commit comments

Comments
 (0)