$page->getId(), 'token' => $this->api->getToken( 'protect' ), ]; $protectionsString = ''; foreach ( $protections as $action => $value ) { if ( !is_string( $action ) || !is_string( $value ) ) { throw new InvalidArgumentException( 'All keys and elements of $protections must be strings' ); } $protectionsString = $action . '=' . $value . '|'; } $params['protections'] = rtrim( $protectionsString, '|' ); $this->api->postRequest( new SimpleRequest( 'protect', array_merge( $extraParams, $params ) ) ); return true; } }