<commit_before><?php

namespace Redmine\Api;

/**
 * Listing Wiki pages
 *
 * @link   http://www.redmine.org/projects/redmine/wiki/Rest_WikiPages
 * @author <NAME> <kevin at saliou dot name>
 */
class Wiki extends AbstractApi
{
    private $wikiPages = array();

    /**
     * List wiki pages of given $project
     * @link http://www.redmine.org/projects/redmine/wiki/Rest_WikiPages#Getting-the-pages-list-of-a-wiki
     *
     * @param  array $params optional parameters to be passed to the api (offset, limit, ...)
     * @return array list of wiki pages found for the given project
     */
    public function all($project, array $params = array())
    {
        $this->wikiPages = $this->retrieveAll('/projects/'.$project.'/wiki/index.json', $params);

        return $this->wikiPages;
    }

    /**
     *
     * Getting [an old version of ] a wiki page
     * @link http://www.redmine.org/projects/redmine/wiki/Rest_WikiPages#Getting-a-wiki-page
     * @link http://www.redmine.org/projects/redmine/wiki/Rest_WikiPages#Getting-an-old-version-of-a-wiki-page
     *
     * @param  int|string $project the project name
     * @param  string     $page    the page name
     * @param  int        $version version of the page
     * @return array      information about the issue
     */
    public function show($project, $page, $version = null)
    {
        $path = null === $version
            ? '/projects/'.$project.'/wiki/'.$page.'.json'
            : '/projects/'.$project.'/wiki/'.$page.'/'.$version.'.json';

        return $this->get($path);
    }

    /**
     * Create a new issue given an array of $params
     * The issue is assigned to the authenticated user.
     * @link http://www.redmine.org/projects/redmine/wiki/Rest_Issues#Creating-an-issue
     *
     * @param  int|string        $project the project name
     * @param  string            $page    the page name
     * @param  array             $params  the new issue data
     * @return \SimpleXMLElement
     */
    public function create($project, $page, array $params = array())
    {
        $defaults = array(
            'text'     => null,
            'comments' => null,
            'version'  => null,
        );
        $params = $this->cleanParams($params);
        $params = array_filter(array_merge($defaults, $params));

        $xml = new \SimpleXMLElement('<?xml version="1.0"?><wiki_page></wiki_page>');
        foreach ($params as $k => $v) {
            $xml->addChild($k, $v);
        }

        return $this->post('/projects/'.$project.'/wiki/'.$page.'.xml', $xml->asXML());
    }

    /**
     * Delete a wiki page
     * @link http://www.redmine.org/projects/redmine/wiki/Rest_WikiPages#Deleting-a-wiki-page
     *
     * @param  int|string $project the project name
     * @param  string     $page    the page name
     * @return string
     */
    public function remove($project, $page)
    {
        return $this->delete('/projects/'.$project.'/wiki/'.$page.'.xml');
    }
}<commit_msg>fixes #53 wiki::create() should put rather than post<commit_after><?php

namespace Redmine\Api;

/**
 * Listing Wiki pages
 *
 * @link   http://www.redmine.org/projects/redmine/wiki/Rest_WikiPages
 * @author <NAME> <kevin at saliou dot name>
 */
class Wiki extends AbstractApi
{
    private $wikiPages = array();

    /**
     * List wiki pages of given $project
     * @link http://www.redmine.org/projects/redmine/wiki/Rest_WikiPages#Getting-the-pages-list-of-a-wiki
     *
     * @param  array $params optional parameters to be passed to the api (offset, limit, ...)
     * @return array list of wiki pages found for the given project
     */
    public function all($project, array $params = array())
    {
        $this->wikiPages = $this->retrieveAll('/projects/'.$project.'/wiki/index.json', $params);

        return $this->wikiPages;
    }

    /**
     *
     * Getting [an old version of ] a wiki page
     * @link http://www.redmine.org/projects/redmine/wiki/Rest_WikiPages#Getting-a-wiki-page
     * @link http://www.redmine.org/projects/redmine/wiki/Rest_WikiPages#Getting-an-old-version-of-a-wiki-page
     *
     * @param  int|string $project the project name
     * @param  string     $page    the page name
     * @param  int        $version version of the page
     * @return array      information about the issue
     */
    public function show($project, $page, $version = null)
    {
        $path = null === $version
            ? '/projects/'.$project.'/wiki/'.$page.'.json'
            : '/projects/'.$project.'/wiki/'.$page.'/'.$version.'.json';

        return $this->get($path);
    }

    /**
     * Create a new issue given an array of $params
     * The issue is assigned to the authenticated user.
     * @link http://www.redmine.org/projects/redmine/wiki/Rest_Issues#Creating-an-issue
     *
     * @param  int|string        $project the project name
     * @param  string            $page    the page name
     * @param  array             $params  the new issue data
     * @return \SimpleXMLElement
     */
    public function create($project, $page, array $params = array())
    {
        $defaults = array(
            'text'     => null,
            'comments' => null,
            'version'  => null,
        );
        $params = array_filter(array_merge($defaults, $params));

        $xml = new \SimpleXMLElement('<?xml version="1.0"?><wiki_page></wiki_page>');
        foreach ($params as $k => $v) {
            $xml->addChild($k, $v);
        }

        return $this->put('/projects/'.$project.'/wiki/'.$page.'.xml', $xml->asXML());
    }

    /**
     * Delete a wiki page
     * @link http://www.redmine.org/projects/redmine/wiki/Rest_WikiPages#Deleting-a-wiki-page
     *
     * @param  int|string $project the project name
     * @param  string     $page    the page name
     * @return string
     */
    public function remove($project, $page)
    {
        return $this->delete('/projects/'.$project.'/wiki/'.$page.'.xml');
    }
}
{'fraction_non_alphanumeric': 0.1509623430962343, 'fraction_numerical': 0.0010041841004184101, 'mean_word_length': 2.2337662337662336, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 2, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 12, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7024350', 'n_tokens_mistral': 1852, 'n_tokens_neox': 1832, 'n_words': 435}