Skip to content

Instantly share code, notes, and snippets.

@emanh1
Created November 23, 2016 13:43
Show Gist options
  • Select an option

  • Save emanh1/64be71cfc33e9a1eacac87ed60278275 to your computer and use it in GitHub Desktop.

Select an option

Save emanh1/64be71cfc33e9a1eacac87ed60278275 to your computer and use it in GitHub Desktop.
<?php
/*
WildPHP - a modular and easily extendable IRC bot written in PHP
Copyright (C) 2015 WildPHP
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace WildPHP\API;
class Validation
{
/**
* @param string $chan
* @return bool
*/
public static function isChannelName($chan)
{
$pmatch = preg_match('/^(?:\&|\#|\+|\!)[^,\cG ]+$/', $chan);
return $pmatch !== 0 && $pmatch !== false;
}
/**
* @param string $nick
* @return bool
*/
public static function isNickname($nick)
{
$pmatch = preg_match("/^[^@\n\r ]+$/", $nick);
return $pmatch !== 0 && $pmatch !== false;
}
/**
* @param string $uri
* @return bool
*/
public static function isValidLink($uri)
{
return filter_var($uri, FILTER_VALIDATE_URL) == $uri;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment