Skip to content
Snippets Groups Projects
Commit 1c1db71b authored by Marcin Kolanko's avatar Marcin Kolanko
Browse files

added support for has method

parent 05fbe977
Branches feature/changed-access-level
Tags
1 merge request!3Feature/changed access level
......@@ -40,6 +40,15 @@ final class DelaySinglePersistentContainer implements DelayPersistentContainer {
throw new ElementNotExistsException( sprintf( 'Element %s not exists!', $id ) );
}
public function has( $id ) {
if ( isset( $this->changed[ $id ] ) && $this->changed[ $id ] ) {
return isset( $this->internal_data[ $id ] );
}
$data = \maybe_unserialize( $this->container->get( $this->key ) );
return is_array( $data ) && isset( $data[ $id ] );
}
public function save() {
if ( $this->is_changed() ) {
$this->container->set( $this->key, \maybe_serialize( $this->internal_data ) );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment