HEX
Server: Apache
System: Linux efa57bbe-abb1-400d-2985-3b056fbc2701.secureserver.net 6.1.147-1.el9.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jul 24 12:33:32 EDT 2025 x86_64
User: root (0)
PHP: 8.0.30.4
Disabled: NONE
Upload Files
File: /var/www/wp-content/mu-plugins/vendor/wpsec/wp-2fa-plugin/src/Services/container/Container.php
<?php

namespace Wpsec\twofa\Services\container;

# This implementation of container is modified Pipmle container implementation https://github.com/silexphp/Pimple/blob/main/src/Pimple/Container.php

class Container implements \ArrayAccess {

	private $values = array();
	private $raw    = array();
	private $keys   = array();


	public function __construct( array $values = array() ) {
		foreach ( $values as $key => $value ) {
			$this->offsetSet( $key, $value );
		}
	}

	public function offsetSet( $id, $value ): void {
		$this->values[ $id ] = $value;
		$this->keys[ $id ]   = true;
	}

	#[\ReturnTypeWillChange]
	public function offsetGet( $id ) {

		if ( ! isset( $this->keys[ $id ] ) ) {
			throw new \Exception( \sprintf( 'Service "%s" is not defined.', $id ) );
		}

		if (
			isset( $this->raw[ $id ] )
			|| ! \is_object( $this->values[ $id ] )
			|| ! \method_exists( $this->values[ $id ], '__invoke' )
		) {
			return $this->values[ $id ];
		}

		$raw                 = $this->values[ $id ];
		$val                 = $raw( $this );
		$this->values[ $id ] = $val;
		$this->raw[ $id ]    = $raw;

		return $val;
	}

	public function offsetExists( $id ): bool {
		return isset( $this->keys[ $id ] );
	}

	public function offsetUnset( $id ): void {
		if ( isset( $this->keys[ $id ] ) ) {
			unset( $this->values[ $id ], $this->raw[ $id ], $this->keys[ $id ] );
		}
	}
}