<commit_before><?php
namespace Kunstmaan\Skylab\Skeleton;

/**
 * ApacheSkeleton
 */
class PingdomSkeleton extends AbstractSkeleton
{

    const NAME = "pingdom";

    /**
     * @return string
     */
    public function getName()
    {
        return self::NAME;
    }

    /**
     * @param \ArrayObject $project
     *
     * @return mixed
     */
    public function create(\ArrayObject $project)
    {

    }
    /**
     * @return mixed
     */
    public function preMaintenance()
    {
        // TODO: Implement preMaintenance() method.
    }

    /**
     * @return mixed
     */
    public function postMaintenance()
    {
        // TODO: Implement postMaintenance() method.
    }

    /**
     * @param \ArrayObject $project
     *
     * @return mixed
     */
    public function maintenance(\ArrayObject $project)
    {

        $contactIds = $this->app["config"]["pingdom"]["contactids"];
        $username   = $this->app["config"]["pingdom"]["username"];
        $password   = $this->app["config"]["pingdom"]["password"];
        $token      = $this->app["config"]["pingdom"]["token"];

        if (!(empty($contactIds) && empty($username) && empty($password) && empty($token))){
            $pingdom = new \Pingdom\Client($username, $password, $token);

            $checkId=$pingdom->getCheck($project['name']);
            if (!is_null($checkId)){
                $pingdom->updateHTTPCheck($checkId, $project['name'], $project['url'], "/", "true", "true", "true", $contactIds);
            }else{
                $pingdom->addHTTPCheck($project['name'], $project['url'], "/", "true", "true", "true", $contactIds);
            }
        }
    }

    /**
     * @param \ArrayObject $project
     *
     * @return mixed
     */
    public function preBackup(\ArrayObject $project)
    {
        // TODO: Implement preBackup() method.
    }

    /**
     * @param \ArrayObject $project
     *
     * @return mixed
     */
    public function postBackup(\ArrayObject $project)
    {
        // TODO: Implement postBackup() method.
    }

    /**
     * @param \ArrayObject $project
     *
     * @return mixed
     */
    public function preRemove(\ArrayObject $project)
    {
        // TODO: Implement preRemove() method.
    }

    /**
     * @param \ArrayObject $project
     *
     * @return mixed
     */
    public function postRemove(\ArrayObject $project)
    {
        $username = $this->app["config"]["pingdom"]["username"];
        $password = $this->app["config"]["pingdom"]["password"];
        $token    = $this->app["config"]["pingdom"]["token"];

        $pingdom = new \Pingdom\Client($username, $password, $token);

        foreach ($pingdom->getAllChecks() as $key => $value) {
            if($value['name'] == $project['name']){
                $pingdom->removeCheck($value['id']);
            }
        }
    }

    /**
     * @return string[]
     */
    public function dependsOn()
    {
        return array("base", "apache");
    }

}<commit_msg>Check if pingdom credentials are configured<commit_after><?php
namespace Kunstmaan\Skylab\Skeleton;

/**
 * ApacheSkeleton
 */
class PingdomSkeleton extends AbstractSkeleton
{

    const NAME = "pingdom";

    /**
     * @return string
     */
    public function getName()
    {
        return self::NAME;
    }

    /**
     * @param \ArrayObject $project
     *
     * @return mixed
     */
    public function create(\ArrayObject $project)
    {

    }
    /**
     * @return mixed
     */
    public function preMaintenance()
    {
        // TODO: Implement preMaintenance() method.
    }

    /**
     * @return mixed
     */
    public function postMaintenance()
    {
        // TODO: Implement postMaintenance() method.
    }

    /**
     * @param \ArrayObject $project
     *
     * @return mixed
     */
    public function maintenance(\ArrayObject $project)
    {

        $contactIds = $this->app["config"]["pingdom"]["contactids"];
        $username   = $this->app["config"]["pingdom"]["username"];
        $password   = $this->app["config"]["pingdom"]["password"];
        $token      = $this->app["config"]["pingdom"]["token"];

        if (!(empty($contactIds) && empty($username) && empty($password) && empty($token))){
            $pingdom = new \Pingdom\Client($username, $password, $token);

            $checkId=$pingdom->getCheck($project['name']);
            if (!is_null($checkId)){
                $pingdom->updateHTTPCheck($checkId, $project['name'], $project['url'], "/", "true", "true", "true", $contactIds);
            }else{
                $pingdom->addHTTPCheck($project['name'], $project['url'], "/", "true", "true", "true", $contactIds);
            }
        }
    }

    /**
     * @param \ArrayObject $project
     *
     * @return mixed
     */
    public function preBackup(\ArrayObject $project)
    {
        // TODO: Implement preBackup() method.
    }

    /**
     * @param \ArrayObject $project
     *
     * @return mixed
     */
    public function postBackup(\ArrayObject $project)
    {
        // TODO: Implement postBackup() method.
    }

    /**
     * @param \ArrayObject $project
     *
     * @return mixed
     */
    public function preRemove(\ArrayObject $project)
    {
        // TODO: Implement preRemove() method.
    }

    /**
     * @param \ArrayObject $project
     *
     * @return mixed
     */
    public function postRemove(\ArrayObject $project)
    {
        $username = $this->app["config"]["pingdom"]["username"];
        $password = $this->app["config"]["pingdom"]["password"];
        $token    = $this->app["config"]["pingdom"]["token"];

        if (!(empty($contactIds) && empty($username) && empty($password) && empty($token))){
            $pingdom = new \Pingdom\Client($username, $password, $token);

            foreach ($pingdom->getAllChecks() as $key => $value) {
                if($value['name'] == $project['name']){
                    $pingdom->removeCheck($value['id']);
                }
            }
        }
    }

    /**
     * @return string[]
     */
    public function dependsOn()
    {
        return array("base", "apache");
    }

}
{'fraction_non_alphanumeric': 0.17332463720854394, 'fraction_numerical': 0.0, 'mean_word_length': 2.0870659285354805, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '6640411', 'n_tokens_mistral': 1782, 'n_tokens_neox': 1819, 'n_words': 338}