Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php /** * @link https://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Soft..
Decoded Output download
<?php
/**
* @link https://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license https://www.yiiframework.com/license/
*/
namespace yiiunitramework\console\controllers;
use Yii;
use yii\helpers\FileHelper;
use yii\i18n\GettextPoFile;
/**
* Tests that [[\yii\console\controllers\MessageController]] works as expected with PO message format.
*/
class POMessageControllerTest extends BaseMessageControllerTest
{
protected $messagePath;
protected $catalog = 'messages';
protected function setUp(): void
{
parent::setUp();
$this->messagePath = Yii::getAlias('@yiiunit/runtime/test_messages');
FileHelper::createDirectory($this->messagePath, 0777);
}
protected function tearDown(): void
{
parent::tearDown();
FileHelper::removeDirectory($this->messagePath);
}
/**
* {@inheritdoc}
*/
protected function getDefaultConfig()
{
return [
'format' => 'po',
'languages' => [$this->language],
'sourcePath' => $this->sourcePath,
'messagePath' => $this->messagePath,
'overwrite' => true,
];
}
/**
* @return string message file path
*/
protected function getMessageFilePath()
{
return $this->messagePath . '/' . $this->language . '/' . $this->catalog . '.po';
}
/**
* {@inheritdoc}
*/
protected function saveMessages($messages, $category)
{
$messageFilePath = $this->getMessageFilePath();
FileHelper::createDirectory(dirname($messageFilePath), 0777);
$gettext = new GettextPoFile();
$data = [];
foreach ($messages as $message => $translation) {
$data[$category . chr(4) . $message] = $translation;
}
$gettext->save($messageFilePath, $data);
}
/**
* {@inheritdoc}
*/
protected function loadMessages($category)
{
$messageFilePath = $this->getMessageFilePath();
if (!file_exists($messageFilePath)) {
return [];
}
$gettext = new GettextPoFile();
return $gettext->load($messageFilePath, $category);
}
}
?>
Did this file decode correctly?
Original Code
<?php
/**
* @link https://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license https://www.yiiframework.com/license/
*/
namespace yiiunit\framework\console\controllers;
use Yii;
use yii\helpers\FileHelper;
use yii\i18n\GettextPoFile;
/**
* Tests that [[\yii\console\controllers\MessageController]] works as expected with PO message format.
*/
class POMessageControllerTest extends BaseMessageControllerTest
{
protected $messagePath;
protected $catalog = 'messages';
protected function setUp(): void
{
parent::setUp();
$this->messagePath = Yii::getAlias('@yiiunit/runtime/test_messages');
FileHelper::createDirectory($this->messagePath, 0777);
}
protected function tearDown(): void
{
parent::tearDown();
FileHelper::removeDirectory($this->messagePath);
}
/**
* {@inheritdoc}
*/
protected function getDefaultConfig()
{
return [
'format' => 'po',
'languages' => [$this->language],
'sourcePath' => $this->sourcePath,
'messagePath' => $this->messagePath,
'overwrite' => true,
];
}
/**
* @return string message file path
*/
protected function getMessageFilePath()
{
return $this->messagePath . '/' . $this->language . '/' . $this->catalog . '.po';
}
/**
* {@inheritdoc}
*/
protected function saveMessages($messages, $category)
{
$messageFilePath = $this->getMessageFilePath();
FileHelper::createDirectory(dirname($messageFilePath), 0777);
$gettext = new GettextPoFile();
$data = [];
foreach ($messages as $message => $translation) {
$data[$category . chr(4) . $message] = $translation;
}
$gettext->save($messageFilePath, $data);
}
/**
* {@inheritdoc}
*/
protected function loadMessages($category)
{
$messageFilePath = $this->getMessageFilePath();
if (!file_exists($messageFilePath)) {
return [];
}
$gettext = new GettextPoFile();
return $gettext->load($messageFilePath, $category);
}
}
Function Calls
None |
Stats
MD5 | 521d40a714d9b729f55180a082143893 |
Eval Count | 0 |
Decode Time | 88 ms |