Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions src/FreeDSx/Ldap/Entry/Entries.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,28 @@
return false;
}


/**
* Check whether or not an entry (either an Entry object or string DN) exists within the entries.
*
* @param Entry|Dn|string $entry
* @return bool
*/
public function hasCaseInsensitive($entry): bool

Check warning on line 89 in src/FreeDSx/Ldap/Entry/Entries.php

View check run for this annotation

Codecov / codecov/patch

src/FreeDSx/Ldap/Entry/Entries.php#L89

Added line #L89 was not covered by tests
{
if ($entry instanceof Entry) {
return (\array_search($entry, $this->entries, true) !== false);

Check warning on line 92 in src/FreeDSx/Ldap/Entry/Entries.php

View check run for this annotation

Codecov / codecov/patch

src/FreeDSx/Ldap/Entry/Entries.php#L91-L92

Added lines #L91 - L92 were not covered by tests
}

foreach ($this->entries as $entryObj) {
if ((string) strtolower($entry) === strtolower($entryObj->getDn()->toString())) {
return true;

Check warning on line 97 in src/FreeDSx/Ldap/Entry/Entries.php

View check run for this annotation

Codecov / codecov/patch

src/FreeDSx/Ldap/Entry/Entries.php#L95-L97

Added lines #L95 - L97 were not covered by tests
}
}

return false;

Check warning on line 101 in src/FreeDSx/Ldap/Entry/Entries.php

View check run for this annotation

Codecov / codecov/patch

src/FreeDSx/Ldap/Entry/Entries.php#L101

Added line #L101 was not covered by tests
}

/**
* Get an entry from the collection by its DN.
*
Expand All @@ -95,6 +117,23 @@

return null;
}

/**
* Get an entry from the collection by its DN.
*
* @param string $dn
* @return Entry|null
*/
public function getCaseInsensitive(string $dn): ?Entry

Check warning on line 127 in src/FreeDSx/Ldap/Entry/Entries.php

View check run for this annotation

Codecov / codecov/patch

src/FreeDSx/Ldap/Entry/Entries.php#L127

Added line #L127 was not covered by tests
{
foreach ($this->entries as $entry) {
if (strtolower($entry->getDn()->toString()) === strtolower($dn)) {
return $entry;

Check warning on line 131 in src/FreeDSx/Ldap/Entry/Entries.php

View check run for this annotation

Codecov / codecov/patch

src/FreeDSx/Ldap/Entry/Entries.php#L129-L131

Added lines #L129 - L131 were not covered by tests
}
}

return null;

Check warning on line 135 in src/FreeDSx/Ldap/Entry/Entries.php

View check run for this annotation

Codecov / codecov/patch

src/FreeDSx/Ldap/Entry/Entries.php#L135

Added line #L135 was not covered by tests
}

/**
* Get the first entry object, if one exists.
Expand Down