*/
public function up(Schema $schema)
{
- $this->skipIf($this->connection->getDatabasePlatform()->getName() === 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');
+ $this->skipIf('sqlite' === $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');
// remove all FK from entry_tag
switch ($this->connection->getDatabasePlatform()->getName()) {
*/
public function up(Schema $schema)
{
- $this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
+ $this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration only apply to MySQL');
$this->addSql('ALTER DATABASE ' . $this->connection->getParams()['dbname'] . ' CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;');
*/
public function down(Schema $schema)
{
- $this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
+ $this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration only apply to MySQL');
$this->addSql('ALTER DATABASE ' . $this->connection->getParams()['dbname'] . ' CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;');
$clientsTable->dropColumn('user_id', 'integer');
- if ($this->connection->getDatabasePlatform()->getName() !== 'sqlite') {
+ if ('sqlite' !== $this->connection->getDatabasePlatform()->getName()) {
$clientsTable->removeForeignKey($this->constraintName);
}
}
*/
public function up(Schema $schema)
{
- $this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
+ $this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration only apply to MySQL');
foreach ($this->fields as $field) {
$this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE ' . $field . ' ' . $field . ' VARCHAR(180) NOT NULL;');
*/
public function down(Schema $schema)
{
- $this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
+ $this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration only apply to MySQL');
foreach ($this->fields as $field) {
$this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE ' . $field . ' ' . $field . ' VARCHAR(255) NOT NULL;');
*/
public function up(Schema $schema)
{
- $this->skipIf($this->connection->getDatabasePlatform()->getName() === 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');
+ $this->skipIf('sqlite' === $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');
// Find tags which need to be merged
$dupTags = $this->connection->query('
$em = $this->getDoctrine()->getManager();
foreach ($tags as $tag) {
- if (count($tag->getEntries()) === 0) {
+ if (0 === count($tag->getEntries())) {
$em->remove($tag);
}
}
'%s/%s%s user(s) displayed.',
count($users),
$nbUsers,
- $input->getArgument('search') === null ? '' : ' (filtered)'
+ null === $input->getArgument('search') ? '' : ' (filtered)'
)
);
sprintf('Email: %s', $user->getEmail()),
sprintf('Display name: %s', $user->getName()),
sprintf('Creation date: %s', $user->getCreatedAt()->format('Y-m-d H:i:s')),
- sprintf('Last login: %s', $user->getLastLogin() !== null ? $user->getLastLogin()->format('Y-m-d H:i:s') : 'never'),
+ sprintf('Last login: %s', null !== $user->getLastLogin() ? $user->getLastLogin()->format('Y-m-d H:i:s') : 'never'),
sprintf('2FA activated: %s', $user->isTwoFactorAuthentication() ? 'yes' : 'no'),
]);
}
$em = $this->getDoctrine()->getManager();
foreach ($tags as $tag) {
- if (count($tag->getEntries()) === 0) {
+ if (0 === count($tag->getEntries())) {
$em->remove($tag);
}
}
public function showUnreadAction(Request $request, $page)
{
// load the quickstart if no entry in database
- if ((int) $page === 1 && $this->get('wallabag_core.entry_repository')->countAllEntriesByUser($this->getUser()->getId()) === 0) {
+ if (1 === (int) $page && 0 === $this->get('wallabag_core.entry_repository')->countAllEntriesByUser($this->getUser()->getId())) {
return $this->redirect($this->generateUrl('quickstart'));
}
$methodBuilder = 'getBuilderFor' . $method . 'ByUser';
$repository = $this->get('wallabag_core.entry_repository');
- if ($category === 'tag_entries') {
+ if ('tag_entries' === $category) {
$tag = $this->get('wallabag_core.tag_repository')->findOneBySlug($request->query->get('tag'));
$entries = $repository->findAllByTagId(
$em->flush();
// remove orphan tag in case no entries are associated to it
- if (count($tag->getEntries()) === 0) {
+ if (0 === count($tag->getEntries())) {
$em->remove($tag);
$em->flush();
}
$classMetadata->setPrimaryTable(['name' => $this->prefix . $classMetadata->getTableName()]);
foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) {
- if ($mapping['type'] === ClassMetadataInfo::MANY_TO_MANY && isset($classMetadata->associationMappings[$fieldName]['joinTable']['name'])) {
+ if (ClassMetadataInfo::MANY_TO_MANY === $mapping['type'] && isset($classMetadata->associationMappings[$fieldName]['joinTable']['name'])) {
$mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name'];
$classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix . $mappedTableName;
}
*/
public function reverseTransform($string)
{
- if ($string === null) {
+ if (null === $string) {
return;
}
{
// required by credentials below
$host = strtolower($host);
- if (substr($host, 0, 4) === 'www.') {
+ if ('www.' === substr($host, 0, 4)) {
$host = substr($host, 4);
}
$extraFields = [];
foreach ($extraFieldsStrings as $extraField) {
- if (strpos($extraField, '=') === false) {
+ if (false === strpos($extraField, '=')) {
continue;
}
$date = $value;
// is it a timestamp?
- if (filter_var($date, FILTER_VALIDATE_INT) !== false) {
+ if (false !== filter_var($date, FILTER_VALIDATE_INT)) {
$date = '@' . $date;
}
{
public function __invoke($subject, $pattern)
{
- if ($pattern[0] === "'") {
+ if ("'" === $pattern[0]) {
$pattern = sprintf("'%%%s%%'", substr($pattern, 1, -1));
}
{
public function __invoke($subject, $pattern)
{
- if ($pattern[0] === "'") {
+ if ("'" === $pattern[0]) {
$pattern = sprintf("'%%%s%%'", substr($pattern, 1, -1));
}
{
public function __invoke($subject, $pattern)
{
- return stripos($subject, $pattern) !== false;
+ return false !== stripos($subject, $pattern);
}
}
{
public function __invoke($subject, $pattern)
{
- return stripos($subject, $pattern) === false;
+ return false === stripos($subject, $pattern);
}
}
$entryToBeFlushed[] = $entry;
// flush every 20 entries
- if (($i % 20) === 0) {
+ if (0 === ($i % 20)) {
$this->em->flush();
foreach ($entryToBeFlushed as $entry) {
$entryToBeFlushed[] = $entry;
// flush every 20 entries
- if (($i % 20) === 0) {
+ if (0 === ($i % 20)) {
$this->em->flush();
foreach ($entryToBeFlushed as $entry) {
'created_at' => substr($entry['date_added'], 0, 10),
];
- if (array_key_exists('tags', $entry) && $entry['tags'] !== '') {
+ if (array_key_exists('tags', $entry) && '' !== $entry['tags']) {
$data['tags'] = $entry['tags'];
}
'created_at' => substr($entry['dateAdded'], 0, 10),
];
- if (array_key_exists('tags', $entry) && $entry['tags'] !== '') {
+ if (array_key_exists('tags', $entry) && '' !== $entry['tags']) {
$data['tags'] = $entry['tags'];
}
$entries = [];
$handle = fopen($this->filepath, 'r');
- while (($data = fgetcsv($handle, 10240)) !== false) {
+ while (false !== ($data = fgetcsv($handle, 10240))) {
if ('URL' === $data[0]) {
continue;
}
'url' => $data[0],
'title' => $data[1],
'status' => $data[3],
- 'is_archived' => $data[3] === 'Archive' || $data[3] === 'Starred',
- 'is_starred' => $data[3] === 'Starred',
+ 'is_archived' => 'Archive' === $data[3] || 'Starred' === $data[3],
+ 'is_starred' => 'Starred' === $data[3],
'html' => false,
'tags' => $tags,
];
// - first call get 5k offset 0
// - second call get 5k offset 5k
// - and so on
- if (count($entries['list']) === self::NB_ELEMENTS) {
+ if (self::NB_ELEMENTS === count($entries['list'])) {
++$run;
return $this->import(self::NB_ELEMENTS * $run);
*/
public function parseEntry(array $importedEntry)
{
- $url = isset($importedEntry['resolved_url']) && $importedEntry['resolved_url'] !== '' ? $importedEntry['resolved_url'] : $importedEntry['given_url'];
+ $url = isset($importedEntry['resolved_url']) && '' !== $importedEntry['resolved_url'] ? $importedEntry['resolved_url'] : $importedEntry['given_url'];
$existingEntry = $this->em
->getRepository('WallabagCoreBundle:Entry')
$this->fetchContent($entry, $url);
// 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted
- $entry->setArchived($importedEntry['status'] === 1 || $this->markAsRead);
+ $entry->setArchived(1 === $importedEntry['status'] || $this->markAsRead);
// 0 or 1 - 1 If the item is starred
- $entry->setStarred($importedEntry['favorite'] === 1);
+ $entry->setStarred(1 === $importedEntry['favorite']);
$title = 'Untitled';
- if (isset($importedEntry['resolved_title']) && $importedEntry['resolved_title'] !== '') {
+ if (isset($importedEntry['resolved_title']) && '' !== $importedEntry['resolved_title']) {
$title = $importedEntry['resolved_title'];
- } elseif (isset($importedEntry['given_title']) && $importedEntry['given_title'] !== '') {
+ } elseif (isset($importedEntry['given_title']) && '' !== $importedEntry['given_title']) {
$title = $importedEntry['given_title'];
}
$data['html'] = $this->fetchingErrorMessage;
}
- if (array_key_exists('tags', $entry) && $entry['tags'] !== '') {
+ if (array_key_exists('tags', $entry) && '' !== $entry['tags']) {
$data['tags'] = $entry['tags'];
}