Skip to content

Commit 2d1c425

Browse files
ghalsetvdijen
authored andcommitted
Convert checks to assertions
1 parent 2ba870b commit 2d1c425

1 file changed

Lines changed: 14 additions & 20 deletions

File tree

src/Auth/Process/Fticks.php

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -265,29 +265,23 @@ public function __construct(array $config, $reserved)
265265
}
266266

267267
if (array_key_exists('pnHashIsTargeted', $config)) {
268-
if (
269-
is_string($config['pnHashIsTargeted']) &&
270-
in_array($config['pnHashIsTargeted'], ['source', 'destination', 'both', 'none'])
271-
) {
272-
$this->pnHashIsTargeted = $config['pnHashIsTargeted'];
273-
} else {
274-
throw new Error\Exception(
275-
'F-ticks log pnHashIsTargeted must be one of [source, destnation, both, none]',
276-
);
277-
}
268+
Assert::string($config['pnHashIsTargeted'], 'pnHashIsTargeted must be a string');
269+
Assert::oneOf(
270+
$config['pnHashIsTargeted'],
271+
['source', 'destination', 'both', 'none'],
272+
'pnHashIsTargeted must be one of [source, destnation, both, none]',
273+
);
274+
$this->pnHashIsTargeted = $config['pnHashIsTargeted'];
278275
}
279276

280277
if (array_key_exists('logdest', $config)) {
281-
if (
282-
is_string($config['logdest']) &&
283-
in_array($config['logdest'], ['local', 'syslog', 'remote', 'stdout', 'errorlog', 'simplesamlphp'])
284-
) {
285-
$this->logdest = $config['logdest'];
286-
} else {
287-
throw new Error\Exception(
288-
'F-ticks log destination must be one of [local, remote, stdout, errorlog, simplesamlphp]',
289-
);
290-
}
278+
Assert::string($config['logdest'], 'F-ticks log destination must be a string');
279+
Assert::oneOf(
280+
$config['logdest'],
281+
['local', 'syslog', 'remote', 'stdout', 'errorlog', 'simplesamlphp'],
282+
'F-ticks log destination must be one of [local, remote, stdout, errorlog, simplesamlphp]',
283+
);
284+
$this->logdest = $config['logdest'];
291285
}
292286

293287
/* match SSP config or we risk mucking up the openlog call */

0 commit comments

Comments
 (0)