当前位置: 首页>>代码示例>>PHP>>正文


PHP RuntimeException函数代码示例

本文整理汇总了PHP中RuntimeException函数的典型用法代码示例。如果您正苦于以下问题:PHP RuntimeException函数的具体用法?PHP RuntimeException怎么用?PHP RuntimeException使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了RuntimeException函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: verifyConsole

 protected function verifyConsole()
 {
     $request = $this->getRequest();
     if (!$request instanceof ConsoleRequest) {
         throw RuntimeException(sprintf('%s can only be run via the Console', __METHOD__));
     }
 }
开发者ID:Tony133,项目名称:zf-web,代码行数:7,代码来源:ConsoleController.php

示例2: getRestaurantUri

 /** @inheritdoc */
 public function getRestaurantUri($restaurantId)
 {
     $config = $this->configRestaurant($restaurantId);
     if (isset($config['uri'])) {
         return $config['uri'];
     }
     throw \RuntimeException('Restaurant has no URI configured');
 }
开发者ID:tomaskadlec,项目名称:lunch_guy,代码行数:9,代码来源:Application.php

示例3: createTwigFileSystemLoader

 public function createTwigFileSystemLoader()
 {
     $dir = $this->getTemplateDir();
     if (!file_exists($dir)) {
         throw RuntimeException("Directory {$dir} for TemplateView does not exist.");
     }
     return new Twig_Loader_Filesystem($dir);
 }
开发者ID:corneltek,项目名称:phifty,代码行数:8,代码来源:TemplateView.php

示例4: charger

 public static function charger()
 {
     if (null !== self::$_instance) {
         throw new RuntimeException(sprintf('%s is already started', __CLASS__));
     }
     self::$_instance = new self();
     if (!spl_autoload_register(array(self::$_instance, '_autoload'), false)) {
         throw RuntimeException(sprintf('%s : Could not start the autoload', __CLASS__));
     }
 }
开发者ID:unuldur,项目名称:ProjetPhp,代码行数:10,代码来源:Autoload.php

示例5: getEventName

 public function getEventName()
 {
     if (empty($this->eventName)) {
         if (!static::EVENT_NAME) {
             throw \RuntimeException('Your must have set one event name');
         }
         return static::EVENT_NAME;
     }
     return $this->eventName;
 }
开发者ID:rsilveira65,项目名称:Marsvin,代码行数:10,代码来源:AbstractLayer.php

示例6: getService

 public function getService($name)
 {
     if ($name === 'solve_media') {
         return $this->app->SolveMediaService;
     } else {
         if ($name === 'recaptcha') {
             return $this->app->RecaptchaService;
         }
     }
     throw RuntimeException();
 }
开发者ID:blackout314,项目名称:paytoshi-faucet,代码行数:11,代码来源:CaptchaServiceFactory.php

示例7: _replace

 /**
  * Does file replacements.
  *
  * @param array $matches
  */
 protected function _replace($matches)
 {
     $required = empty($matches[2]) ? $matches[4] : $matches[2];
     $filename = $this->_Scanner->find($required);
     if (!$filename) {
         throw RuntimeException('Could not find dependency');
     }
     if (empty($this->_loaded[$filename])) {
         return $this->input($filename, file_get_contents($filename));
     }
     return '';
 }
开发者ID:nojimage,项目名称:asset_compress,代码行数:17,代码来源:ImportInline.php

示例8: changeAuthenticatedUserAvatar

 /**
  * Create new avatar image for current authenticated user
  * @param string $sUserAvatarFilePath
  * @throws \InvalidArgumentException
  * @throws \RuntimeException
  * @throws \DomainException
  * @throws \LogicException
  * @return \BoilerAppUser\Service\UserAccountService
  */
 public function changeAuthenticatedUserAvatar($sUserAvatarFilePath)
 {
     if (!is_string($sUserAvatarFilePath)) {
         throw new \InvalidArgumentException('User avatar path expects string, "' . gettype($sUserAvatarFilePath) . '" given');
     }
     if (!is_readable($sUserAvatarFilePath)) {
         throw new \InvalidArgumentException('User avatar path "' . $sUserAvatarFilePath . '" is not a readable file path');
     }
     if (!($aImagesInfos = @getimagesize($sUserAvatarFilePath)) || empty($aImagesInfos[2])) {
         \RuntimeException('An error occurred while retrieving user avatar "' . $sUserAvatarFilePath . '" infos');
     }
     switch ($aImagesInfos[2]) {
         case IMAGETYPE_JPEG:
             if (!($oImage = imagecreatefromjpeg($sUserAvatarFilePath))) {
                 throw new \RuntimeException('An error occurred during creating image from "jpeg" user avatar "' . $sUserAvatarFilePath . '"');
             }
             break;
         case IMAGETYPE_GIF:
             if (!($oImage = imagecreatefromgif($sUserAvatarFilePath))) {
                 throw new \RuntimeException('An error occurred during creating image from "gif" user avatar "' . $sUserAvatarFilePath . '"');
             }
             break;
         case IMAGETYPE_PNG:
             if (!($oImage = imagecreatefrompng($sUserAvatarFilePath))) {
                 throw new \RuntimeException('An error occurred during creating image from "png" user avatar "' . $sUserAvatarFilePath . '"');
             }
             break;
         default:
             throw new \DomainException('File type "' . $aImagesInfos[2] . '" is not supported for avatar');
     }
     //Crop image
     if (!($oNewImage = imagecreatetruecolor(128, 128))) {
         throw new \RuntimeException('An error occurred during creating new image for croping user avatar');
     }
     if (!imagecopyresampled($oNewImage, $oImage, 0, 0, 0, 0, 128, 128, imagesx($oImage), imagesy($oImage))) {
         throw new \RuntimeException('An error occurred during croping user avatar');
     }
     $aConfiguration = $this->getServiceLocator()->get('Config');
     if (empty($aConfiguration['paths']['avatarsPath'])) {
         throw new \LogicException('Avatars directory path is undefined');
     }
     if (!is_string($aConfiguration['paths']['avatarsPath'])) {
         throw new \LogicException('Avatars directory path expects string, "' . gettype($aConfiguration['paths']['avatarsPath']) . '" given');
     }
     if (!is_dir($aConfiguration['paths']['avatarsPath'])) {
         throw new \LogicException('Avatars directory path expects string, "' . $aConfiguration['paths']['avatarsPath'] . '" is not a valid directory');
     }
     //Save avatar
     if (!imagepng($oNewImage, $aConfiguration['paths']['avatarsPath'] . DIRECTORY_SEPARATOR . $this->getServiceLocator()->get('AccessControlService')->getAuthenticatedAuthAccess()->getAuthAccessUser()->getUserId() . '-avatar.png')) {
         throw new \RuntimeException('An error occurred during saving user avatar');
     }
     return $this;
 }
开发者ID:zf2-boiler-app,项目名称:app-user,代码行数:62,代码来源:UserAccountService.php

示例9: ensureWritableDir

 public function ensureWritableDir($path, $mode = 0777)
 {
     $dir = $this->getPath($path);
     if (!is_dir($dir)) {
         if (!mkdir($dir, $mode, true)) {
             throw \RuntimeException('Cant Create ' . $dir);
         }
     }
     if (!is_writable($dir)) {
         if (!chmod($dir, $mode)) {
             throw \RuntimeException('Cant Change Permission ' . $dir);
         }
     }
     return true;
 }
开发者ID:nora-worker,项目名称:core,代码行数:15,代码来源:DirectoryNode.php

示例10: actionPerformed

 public function actionPerformed($action)
 {
     switch ($action) {
         case self::do_use:
             $this->state->doUse($this);
             break;
         case self::do_alarm:
             $this->state->doAlarm($this);
             break;
         case self::do_phone:
             $this->state->doPhone($this);
             break;
         default:
             throw RuntimeException(__LINE__ . ' ' . __METHOD__);
             break;
     }
 }
开发者ID:th1209,项目名称:DesignPatternQuestions,代码行数:17,代码来源:main.php

示例11: ensure_directory

 /**
  * ensures a directory exist, by creating it if it does no & it's possible to
  *
  * @param string $dir directory
  */
 function ensure_directory($dir)
 {
     if (file_exists($dir)) {
         if (!is_dir($dir)) {
             throw new InvalidArgumentException($dir);
         }
     } else {
         $dir = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $dir));
         $cDir = '';
         //complete dir
         foreach ($dir as $d) {
             $cDir .= $d . '/';
             if (!file_exists($cDir) && !@mkdir($cDir)) {
                 throw RuntimeException("can't create {$cDir}");
             }
         }
     }
 }
开发者ID:nami-doc,项目名称:sprockets-php,代码行数:23,代码来源:functions.php

示例12: payCallBackAction

 public function payCallBackAction(Request $request, $name)
 {
     $controller = $this;
     $status = $this->doPayNotify($request, $name, function ($success, $order) use(&$controller) {
         if (!$success) {
             return;
         }
         if ($order['targetType'] != 'course') {
             throw \RuntimeException('非课程订单,加入课程失败。');
         }
         $info = array('orderId' => $order['id'], 'remark' => empty($order['data']['note']) ? '' : $order['data']['note']);
         if (!$controller->getCourseService()->isCourseStudent($order['targetId'], $order['userId'])) {
             $controller->getCourseService()->becomeStudent($order['targetId'], $order['userId'], $info);
             $controller->getLogService()->info('order', 'callback_success', "paycalknotify action");
         }
         return;
     });
     $callback = "<script type='text/javascript'>window.location='objc://alipayCallback?" . $status . "';</script>";
     return new Response($callback);
 }
开发者ID:styling,项目名称:LeesPharm,代码行数:20,代码来源:MobileAlipayController.php

示例13: init

 /**
  * Initialize image information
  * @throws RuntimeException
  */
 public function init($file)
 {
     if (!file_exists($file)) {
         throw \InvalidArgumentException("source image does not exists");
     }
     $this->file = $file;
     if (!($info = getimagesize($this->file))) {
         throw new \RuntimeException("source image does not exists : " . $this->file);
     }
     $this->width = $info[0];
     $this->height = $info[1];
     $mime = $info['mime'];
     $this->type = str_replace('image/', '', $mime);
     $func = 'imagecreatefrom' . $this->type;
     if (!function_exists($func)) {
         throw \RuntimeException("Format not supported");
     }
     $this->file = $func($this->file);
     return $this;
 }
开发者ID:renus,项目名称:media,代码行数:24,代码来源:Image.php

示例14: usdMxn

 /**
  * Retrieves the exchange rate of the USD specified in MXN as calculated
  * from "http://dof.gob.mx/indicadores.php".
  *
  * @throws RuntimeException When client could not connect to the webserver
  *         at dof.gob.mx and thus USD value could not be retrieved.
  *
  * @return float
  */
 public function usdMxn()
 {
     $query = http_build_query(['cod_tipo_indicador' => '158', 'dfecha' => Carbon::now()->subMonth()->format('d/m/Y'), 'hfecha' => Carbon::now()->format('d/m/Y')]);
     $url = 'http://dof.gob.mx/indicadores_detalle.php?' . $query;
     $webContent = file_get_contents($url);
     if (!$webContent) {
         throw RuntimeException("Couldn't connect to dof.gob.mx server!");
     }
     $dom = new \DOMDocument();
     libxml_use_internal_errors(true);
     $dom->loadHTML($webContent);
     $items = $dom->getElementsByTagName('tr');
     $entries = [];
     foreach ($items as $tag) {
         if (!$tag->hasAttribute('class')) {
             continue;
         }
         if ($tag->getAttribute('class') != 'Celda 1') {
             continue;
         }
         $entries[] = $this->helpers->parseNodes($tag->childNodes);
     }
     return $this->helpers->mostRecentEntry($entries)['rate'];
 }
开发者ID:zzantares,项目名称:helpers,代码行数:33,代码来源:ExchangeRates.php

示例15: parse

 public function parse()
 {
     throw RuntimeException('It need use parse() function in sub class.');
 }
开发者ID:nise-nabe,项目名称:opCalendarPlugin,代码行数:4,代码来源:opCalendarApiResults.class.php


注:本文中的RuntimeException函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。