Skip to content
Permalink
Browse files

use && and || instead of AND and OR

  • Loading branch information...
konecnyjakub committed Aug 10, 2019
1 parent 83fc0b5 commit 9e215a99749d43f758e5b0e046e78861b6af9be3
@@ -30,7 +30,7 @@ public function setParam(string $param): void {
public function onRequest(Application $application, Request $request): void {
$locale = $request->getParameter($this->param);
if($request->method === Request::FORWARD AND $locale === null) {
if($request->method === Request::FORWARD && $locale === null) {
return;
}
$this->request = $request;
@@ -119,7 +119,7 @@ protected function resolveResolverClass(): array {
$resolver = Arrays::get($this->resolvers, strtolower($resolverName), "");
if($resolver !== "") {
$return[] = $resolver;
} elseif(class_exists($resolverName) AND is_subclass_of($resolverName, ILocaleResolver::class)) {
} elseif(class_exists($resolverName) && is_subclass_of($resolverName, ILocaleResolver::class)) {
$return[] = $resolverName;
} else {
throw new InvalidLocaleResolverException("Invalid locale resolver $resolverName.");
@@ -139,7 +139,7 @@ protected function resolveLoaderClass(): string {
$loader = Arrays::get($this->loaders, strtolower($loaderName), "");
if($loader !== "") {
return $loader;
} elseif(class_exists($loaderName) AND is_subclass_of($loaderName, ILoader::class)) {
} elseif(class_exists($loaderName) && is_subclass_of($loaderName, ILoader::class)) {
return $loaderName;
}
throw new InvalidLoaderException("Invalid translation loader $loaderName.");
@@ -173,7 +173,7 @@ protected function resolveMessageSelector(): string {
$config = $this->getConfig();
/** @var string $messageSelector */
$messageSelector = $config->messageSelector;
if(class_exists($messageSelector) AND is_subclass_of($messageSelector, IMessageSelector::class)) {
if(class_exists($messageSelector) && is_subclass_of($messageSelector, IMessageSelector::class)) {
return $messageSelector;
}
throw new InvalidMessageSelectorException("Invalid message selector $messageSelector.");
@@ -212,7 +212,7 @@ public function loadConfiguration(): void {
$chainResolver->addSetup('$service[] = ?', [$resolverService]);
}
}
if($config->debugger AND interface_exists(\Tracy\IBarPanel::class)) {
if($config->debugger && interface_exists(\Tracy\IBarPanel::class)) {
$builder->addDefinition($this->prefix(static::SERVICE_PANEL))
->setType(TranslationPanel::class);
/** @var ServiceDefinition $tracy */
@@ -105,7 +105,7 @@ public function setFolders(array $folders): void {
}
protected function addResource(string $filename, string $domain): void {
if(!isset($this->resources[$domain]) OR !in_array($filename, $this->resources[$domain], true)) {
if(!isset($this->resources[$domain]) || !in_array($filename, $this->resources[$domain], true)) {
$this->resources[$domain][] = $filename;
}
}
@@ -136,7 +136,7 @@ protected function loadDomain(string $name): array {
$lang = [];
$filename = str_replace($defaultLang, $this->lang, $defaultFilename);
$filename = str_replace($defaultFilename, $filename, $file->getPathname());
if($this->lang != $defaultLang AND is_file($filename)) {
if($this->lang != $defaultLang && is_file($filename)) {
$lang = $this->parseFile($filename);
$this->addResource($filename, $name);
}
@@ -13,7 +13,7 @@
*/
final class MessageSelector implements IMessageSelector {
public function isMultiChoice(string $message): bool {
return is_string(Intervals::findInterval($message)) AND Strings::contains($message, "|");
return is_string(Intervals::findInterval($message)) && Strings::contains($message, "|");
}
public function choose(string $message, int $count): string {
@@ -23,7 +23,7 @@ public function choose(string $message, int $count): string {
$variants = explode("|", $message);
foreach($variants as $variant) {
$interval = Intervals::findInterval($variant);
if(is_string($interval) AND Intervals::isInInterval($count, $interval)) {
if(is_string($interval) && Intervals::isInInterval($count, $interval)) {
return Strings::trim((string) Strings::after($variant, $interval));
}
}
@@ -84,7 +84,7 @@ public function logUntranslatedMessage(string $message): void {
* @param string $message
*/
public function translate($message, ... $parameters): string {
if(count($parameters) === 1 AND is_array($parameters[0])) {
if(count($parameters) === 1 && is_array($parameters[0])) {
$count = $parameters[0]["count"] ?? 0;
$params = $parameters[0];
} else {
@@ -23,7 +23,7 @@ public function choose(string $message, int $count): string {
$variants = explode("|", $message);
foreach($variants as $variant) {
$interval = Intervals::findInterval($variant);
if(is_string($interval) AND Intervals::isInInterval($count, $interval)) {
if(is_string($interval) && Intervals::isInInterval($count, $interval)) {
return Strings::trim(Strings::after($variant, $interval));
}
}

0 comments on commit 9e215a9

Please sign in to comment.
You can’t perform that action at this time.