Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 07bfa76

Browse files
committed
2 parents 5784132 + 07a9158 commit 07bfa76

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/Attribute.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ private static function valueFromLdap($value)
197197
} else {
198198
return $return;
199199
}
200-
} catch (Exception\InvalidArgumentException $e) {
200+
} catch (Converter\Exception\InvalidArgumentException $e) {
201201
return $value;
202202
}
203203
}

src/Converter/Converter.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,15 @@ public static function fromLdapDateTime($date, $asUtc = true)
339339
. $time['offdir']
340340
. str_pad($time['offsethours'], 2, '0', STR_PAD_LEFT)
341341
. str_pad($time['offsetminutes'], 2, '0', STR_PAD_LEFT);
342-
$date = new DateTime($timestring);
342+
try {
343+
$date = new DateTime($timestring);
344+
} catch (\Exception $e) {
345+
throw new Exception\InvalidArgumentException(
346+
'Invalid date format found',
347+
0,
348+
$e
349+
);
350+
}
343351
if ($asUtc) {
344352
$date->setTimezone(new DateTimeZone('UTC'));
345353
}

test/AttributeTest.php

+8
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ public function testGetNonExistentAttributeValue()
5151
$this->assertNull($value);
5252
}
5353

54+
public function testInvalidValue()
55+
{
56+
$data = array('uid' => array('45678+'));
57+
$value = Attribute::getAttribute($data, 'uid', 0);
58+
59+
$this->assertEquals('45678+', $value);
60+
}
61+
5462
public function testGetNonExistentAttribute()
5563
{
5664
$data = array('uid' => array('value'));

0 commit comments

Comments
 (0)