new id, keyed by object type. * * @var array> */ private $map = array(); /** * Record a mapping. * * @param string $object_type Bucket, for example 'post' or 'term'. * @param int $old Source-site id. * @param int $new_id Destination-site id. * @return void */ public function add( string $object_type, int $old, int $new_id ): void { $this->map[ $object_type ][ $old ] = $new_id; } /** * Look up a mapping. * * @param string $object_type Bucket. * @param int $old Source-site id. * @return int|null Null when unmapped. */ public function get( string $object_type, int $old ): ?int { return isset( $this->map[ $object_type ][ $old ] ) ? $this->map[ $object_type ][ $old ] : null; } /** * Whether a mapping exists. * * @param string $object_type Bucket. * @param int $old Source-site id. * @return bool */ public function has( string $object_type, int $old ): bool { return isset( $this->map[ $object_type ][ $old ] ); } /** * Number of mappings in a bucket. * * @param string $object_type Bucket. * @return int */ public function count( string $object_type ): int { return isset( $this->map[ $object_type ] ) ? count( $this->map[ $object_type ] ) : 0; } }