Skip to content

Commit

Permalink
chore: run composer cs:fix
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Steinmetz <[email protected]>
  • Loading branch information
st3iny committed Aug 4, 2024
1 parent ea926f0 commit 3826df3
Show file tree
Hide file tree
Showing 40 changed files with 116 additions and 116 deletions.
2 changes: 1 addition & 1 deletion lib/BackgroundJob/ETLJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ETLJob extends TimedJob {
private $etlService;

public function __construct(ETLService $etlService,
ITimeFactory $time) {
ITimeFactory $time) {
parent::__construct($time);

$this->setInterval(60 * 60);
Expand Down
4 changes: 2 additions & 2 deletions lib/BackgroundJob/TrainJobIpV4.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class TrainJobIpV4 extends TimedJob {
private $logger;

public function __construct(TrainService $trainService,
ILogger $logger,
ITimeFactory $time) {
ILogger $logger,
ITimeFactory $time) {
parent::__construct($time);

$this->setInterval(24 * 60 * 60);
Expand Down
4 changes: 2 additions & 2 deletions lib/BackgroundJob/TrainJobIpV6.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class TrainJobIpV6 extends TimedJob {
private $logger;

public function __construct(TrainService $trainService,
ILogger $logger,
ITimeFactory $time) {
ILogger $logger,
ITimeFactory $time) {
parent::__construct($time);

$this->setInterval(24 * 60 * 60);
Expand Down
2 changes: 1 addition & 1 deletion lib/Command/Seed.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Seed extends Command {
private $seeder;

public function __construct(IConfig $config,
LoginAddressAggregatedSeeder $seeder) {
LoginAddressAggregatedSeeder $seeder) {
parent::__construct("suspiciouslogin:seed");
$this->seeder = $seeder;

Expand Down
4 changes: 2 additions & 2 deletions lib/Command/Train.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class Train extends Command {
private $store;

public function __construct(DataLoader $loader,
Trainer $optimizer,
ModelStore $store) {
Trainer $optimizer,
ModelStore $store) {
parent::__construct("suspiciouslogin:train");
$this->trainer = $optimizer;
$this->loader = $loader;
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/LoginAddressAggregatedSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class LoginAddressAggregatedSeeder {
private $mapper;

public function __construct(IDBConnection $db,
LoginAddressAggregatedMapper $mapper) {
LoginAddressAggregatedMapper $mapper) {
$this->db = $db;
$this->mapper = $mapper;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Listener/LoginListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ class LoginListener implements IEventListener {
private $loginDataCollector;

public function __construct(IRequest $request,
ITimeFactory $timeFactory,
LoginClassifier $loginClassifier,
LoginDataCollector $loginDataCollector) {
ITimeFactory $timeFactory,
LoginClassifier $loginClassifier,
LoginDataCollector $loginDataCollector) {
$this->request = $request;
$this->timeFactory = $timeFactory;
$this->loginDataCollector = $loginDataCollector;
Expand Down
2 changes: 1 addition & 1 deletion lib/Listener/LoginMailListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
namespace OCA\SuspiciousLogin\Listener;

use Exception;
use OCP\IConfig;
use OCA\SuspiciousLogin\Event\SuspiciousLoginEvent;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\IConfig;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IUser;
Expand Down
4 changes: 2 additions & 2 deletions lib/Listener/LoginNotificationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class LoginNotificationListener implements IEventListener {
private $logger;

public function __construct(IManager $notificationManager,
ITimeFactory $timeFactory,
ILogger $logger) {
ITimeFactory $timeFactory,
ILogger $logger) {
$this->notificationManager = $notificationManager;
$this->timeFactory = $timeFactory;
$this->logger = $logger;
Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version0Date20181127130604.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version0Date20181127130604 extends SimpleMigrationStep {

Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version0Date20181213090142.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version0Date20181213090142 extends SimpleMigrationStep {

Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version0Date20181214080456.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version0Date20181214080456 extends SimpleMigrationStep {

Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version0Date20181214083108.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version0Date20181214083108 extends SimpleMigrationStep {

Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version0Date20181214103754.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
use Closure;
use Doctrine\DBAL\Types\Type;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version0Date20181214103754 extends SimpleMigrationStep {

Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version0Date20190115134303.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version0Date20190115134303 extends SimpleMigrationStep {

Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version0Date20190121184304.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version0Date20190121184304 extends SimpleMigrationStep {

Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version0Date20190123142603.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version0Date20190123142603 extends SimpleMigrationStep {

Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version2Date20190906100917.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
use Closure;
use OCA\SuspiciousLogin\Service\Ipv4Strategy;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version2Date20190906100917 extends SimpleMigrationStep {

Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version2Date20190913144908.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version2Date20190913144908 extends SimpleMigrationStep {

Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version4002Date20220922094803.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
use OCP\DB\ISchemaWrapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version4002Date20220922094803 extends SimpleMigrationStep {
/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version4002Date20220922094804.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version4002Date20220922094804 extends SimpleMigrationStep {

Expand Down
4 changes: 2 additions & 2 deletions lib/Notifications/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

namespace OCA\SuspiciousLogin\Notifications;

use OCP\IConfig;
use InvalidArgumentException;
use OCP\IURLGenerator;
use OCA\SuspiciousLogin\AppInfo\Application;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IURLGenerator;
use OCP\L10N\IFactory;
use OCP\Notification\IAction;
use OCP\Notification\INotification;
Expand Down
4 changes: 2 additions & 2 deletions lib/Service/AdminService.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class AdminService {
private $modelMapper;

public function __construct(LoginAddressMapper $loginAddressMapper,
LoginAddressAggregatedMapper $loginAddressAggregatedMapper,
ModelMapper $modelMapper) {
LoginAddressAggregatedMapper $loginAddressAggregatedMapper,
ModelMapper $modelMapper) {
$this->loginAddressMapper = $loginAddressMapper;
$this->loginAddressAggregatedMapper = $loginAddressAggregatedMapper;
$this->modelMapper = $modelMapper;
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/CollectedData.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CollectedData {
private $validationPositives;

public function __construct(Labeled $trainingPositives,
Labeled $validationPositives) {
Labeled $validationPositives) {
$this->trainingPositives = $trainingPositives;
$this->validationPositives = $validationPositives;
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Service/DataLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class DataLoader {
private $negativeSampleGenerator;

public function __construct(LoginAddressAggregatedMapper $loginAddressMapper,
NegativeSampleGenerator $negativeSampleGenerator) {
NegativeSampleGenerator $negativeSampleGenerator) {
$this->loginAddressMapper = $loginAddressMapper;
$this->negativeSampleGenerator = $negativeSampleGenerator;
}
Expand All @@ -44,7 +44,7 @@ public function __construct(LoginAddressAggregatedMapper $loginAddressMapper,
* @throws InsufficientDataException
*/
public function loadTrainingAndValidationData(TrainingDataConfig $dataConfig,
AClassificationStrategy $strategy): CollectedData {
AClassificationStrategy $strategy): CollectedData {
$validationThreshold = $dataConfig->getNow() - $dataConfig->getThreshold() * 60 * 60 * 24;
$maxAge = $dataConfig->getMaxAge() === -1 ? 0 : $dataConfig->getNow() - $dataConfig->getMaxAge() * 60 * 60 * 24;

Expand Down Expand Up @@ -97,8 +97,8 @@ private function addressesToDataSet(array $loginAddresses, AClassificationStrate
* @return TrainingDataSet
*/
public function generateRandomShuffledData(CollectedData $collectedData,
Config $config,
AClassificationStrategy $strategy): TrainingDataSet {
Config $config,
AClassificationStrategy $strategy): TrainingDataSet {
$numPositives = count($collectedData->getTrainingPositives());
$numValidation = count($collectedData->getValidationPositives());
$numRandomNegatives = max((int)floor($numPositives * $config->getRandomNegativeRate()), 1);
Expand Down
8 changes: 4 additions & 4 deletions lib/Service/ETLService.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ class ETLService {
private $logger;

public function __construct(IDBConnection $db,
LoginAddressAggregatedMapper $aggregatedMapper,
ILogger $logger) {
LoginAddressAggregatedMapper $aggregatedMapper,
ILogger $logger) {
$this->db = $db;
$this->aggregatedMapper = $aggregatedMapper;
$this->logger = $logger;
}

private function getRaw(int $max, OutputInterface $output = null): Generator {
private function getRaw(int $max, ?OutputInterface $output = null): Generator {
if (!is_null($output)) {
$progress = new ProgressBar($output);
}
Expand Down Expand Up @@ -68,7 +68,7 @@ private function getRaw(int $max, OutputInterface $output = null): Generator {
/**
* Extract raw login data and feed it into the aggregated table
*/
public function extractAndTransform(int $max = self::MAX_BATCH_SIZE, OutputInterface $output = null) {
public function extractAndTransform(int $max = self::MAX_BATCH_SIZE, ?OutputInterface $output = null) {
$this->logger->debug('starting login data ETL process');
$this->db->beginTransaction();

Expand Down
4 changes: 2 additions & 2 deletions lib/Service/EstimatorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class EstimatorService {
private $logger;

public function __construct(ModelStore $modelStore,
ILogger $logger) {
ILogger $logger) {
$this->modelStore = $modelStore;
$this->logger = $logger;
}
Expand All @@ -36,7 +36,7 @@ public function __construct(ModelStore $modelStore,
* @return bool
* @throws ServiceException
*/
public function predict(string $uid, string $ip, AClassificationStrategy $strategy, int $modelId = null): bool {
public function predict(string $uid, string $ip, AClassificationStrategy $strategy, ?int $modelId = null): bool {
try {
if ($modelId === null) {
$this->logger->debug("loading latest model");
Expand Down
32 changes: 16 additions & 16 deletions lib/Service/LoginClassifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@

namespace OCA\SuspiciousLogin\Service;

use function base64_decode;
use function explode;
use OCA\SuspiciousLogin\Db\SuspiciousLogin;
use OCA\SuspiciousLogin\Db\SuspiciousLoginMapper;
use OCA\SuspiciousLogin\Event\SuspiciousLoginEvent;
use OCA\SuspiciousLogin\Exception\ServiceException;
use OCA\SuspiciousLogin\Util\AddressClassifier;
use OCP\EventDispatcher\IEventDispatcher;
use function preg_match;
use function strlen;
use function substr;
use OCA\SuspiciousLogin\Db\SuspiciousLogin;
use OCA\SuspiciousLogin\Db\SuspiciousLoginMapper;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\ILogger;
use OCP\IRequest;
use Throwable;
use function base64_decode;
use function explode;
use function preg_match;
use function strlen;
use function substr;

class LoginClassifier {

Expand All @@ -46,11 +46,11 @@ class LoginClassifier {
private $dispatcher;

public function __construct(EstimatorService $estimator,
IRequest $request,
ILogger $logger,
SuspiciousLoginMapper $mapper,
ITimeFactory $timeFactory,
IEventDispatcher $dispatcher) {
IRequest $request,
ILogger $logger,
SuspiciousLoginMapper $mapper,
ITimeFactory $timeFactory,
IEventDispatcher $dispatcher) {
$this->estimator = $estimator;
$this->request = $request;
$this->logger = $logger;
Expand Down Expand Up @@ -79,9 +79,9 @@ private function isAuthenticatedWithAppPassword(IRequest $request): bool {
}

return preg_match(
"/^([0-9A-Za-z]{5})-([0-9A-Za-z]{5})-([0-9A-Za-z]{5})-([0-9A-Za-z]{5})-([0-9A-Za-z]{5})$/",
$pwd[1]
) === 1;
"/^([0-9A-Za-z]{5})-([0-9A-Za-z]{5})-([0-9A-Za-z]{5})-([0-9A-Za-z]{5})-([0-9A-Za-z]{5})$/",
$pwd[1]
) === 1;
}

public function process(string $uid, string $ip) {
Expand Down
8 changes: 4 additions & 4 deletions lib/Service/MLP/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ class Config {
private $learningRate;

public function __construct(int $epochs,
int $layers,
float $shuffledNegativeRate,
float $randomNegativeRate,
float $learningRate) {
int $layers,
float $shuffledNegativeRate,
float $randomNegativeRate,
float $learningRate) {
$this->epochs = $epochs;
$this->layers = $layers;
$this->shuffledNegativeRate = $shuffledNegativeRate;
Expand Down
Loading

0 comments on commit 3826df3

Please sign in to comment.