Example #1
0
 function __construct($name, $address)
 {
     Assert::isScalar($name);
     Assert::isScalar($address);
     $this->name = $name;
     $this->address = $address;
 }
 function move($filepath)
 {
     Assert::isScalar($filepath);
     Assert::isTrue(is_dir(dirname($filepath)));
     Assert::isTrue(is_writable(dirname($filepath)));
     return move_uploaded_file($this->getImportedFilepath(), $filepath);
 }
 public function importValue($value)
 {
     if ($value instanceof UnifiedContainer) {
         if ($value->isLazy()) {
             return $this->import(array($this->name => $value->getList()));
         } elseif ($value->getParentObject()->getId() && ($list = $value->getList())) {
             return $this->import(array($this->name => ArrayUtils::getIdsArray($list)));
         } else {
             return parent::importValue(null);
         }
     }
     if (is_array($value)) {
         try {
             if ($this->scalar) {
                 Assert::isScalar(current($value));
             } else {
                 Assert::isInteger(current($value));
             }
             return $this->import(array($this->name => $value));
         } catch (WrongArgumentException $e) {
             return $this->import(array($this->name => ArrayUtils::getIdsArray($value)));
         }
     }
     return parent::importValue($value);
 }
 /**
  * @param ISqlQuery $query
  * @param string $errormsg
  * @param integer $errorno
  */
 function __construct(ISqlQuery $query, $errormsg, $errorno)
 {
     Assert::isScalar($errormsg);
     Assert::isNumeric($errorno);
     parent::__construct($errormsg, $errorno);
     $this->query = $query;
 }
 /**
  * Sets the new URL pattern to use
  *
  * @param string $pattern pattern to set
  *
  * @return PathRewriteRule itself
  */
 function setPattern($pattern)
 {
     Assert::isScalar($pattern);
     $this->urlPattern = '/' . ltrim($pattern, '/');
     $this->parsePattern();
     return $this;
 }
 function __construct($name, $label)
 {
     Assert::isScalar($name);
     Assert::isScalar($label);
     $this->name = $name;
     $this->label = $label;
 }
Example #7
0
 /**
  * @param string $name name of the column
  * @param ISqlType $type SQL type of the column
  */
 function __construct($name, DBTable $table, ISqlType $type)
 {
     Assert::isScalar($name);
     $this->name = $name;
     $this->table = $table;
     $this->type = $type;
 }
 function setDefaultValue($value)
 {
     Assert::isScalar($value, 'default value shall be scalar');
     Assert::isTrue(in_array($value, $this->getAvailableValues()), 'trying to set a default value that is out of options range');
     $this->defaultValue = $value;
     return $this;
 }
 /**
  * @param string $func name of the aggregate
  * @param string $expression property to be used for aggregation
  * @param string $alias optional label for the result of the aggregator
  */
 function __construct($func, $expression = null, $alias = null)
 {
     Assert::isScalar($func);
     $this->func = $func;
     $this->expression = $expression;
     $this->alias = $alias;
 }
Example #10
0
 /**
  * @param string $field name of the column
  * @param string $table optional name of the table that owns the column
  */
 function __construct($field, $table = null)
 {
     Assert::isScalar($field);
     Assert::isScalarOrNull($table);
     $this->field = $field;
     $this->table = $table;
 }
 function __construct($title, $name)
 {
     Assert::isScalar($title);
     Assert::isScalar($name);
     $this->title = $title;
     $this->name = $name;
 }
 /**
  * @param WebRequestDictionary $dictonary
  * @param array $getVars request's $_GET
  * @param array $postVars request's $_POST
  * @param array $cookieVars request's $_COOKIE
  * @param array $filesVars request's $_FILES
  * @param string|null $baseHost optional base host for request's request url (SiteUrl)
  * @param string $baseUri optional base uri
  */
 function __construct(WebRequestDictionary $dictonary, array $getVars, array $postVars, array $cookieVars, array $filesVars, $baseHost = null, $baseUri = '/')
 {
     Assert::isScalar($baseUri);
     $this->dictionary = $dictonary->getFields();
     $this->httpUrl = SiteUrl::import($dictonary, $baseHost, $baseUri);
     $this->vars = array(WebRequestPart::GET => $getVars, WebRequestPart::POST => $postVars, WebRequestPart::COOKIE => $cookieVars, WebRequestPart::FILES => $filesVars);
     $this->allVars = call_user_func_array('array_merge', array($filesVars, $cookieVars, $postVars, $getVars));
 }
 /**
  * @throws FileNotFoundException thrown when the path to a file is wrong
  * @param string $layoutPath path to PHP file
  */
 function __construct($layoutPath)
 {
     Assert::isScalar($layoutPath);
     $this->layoutPath = $layoutPath;
     if (!file_exists($layoutPath)) {
         throw new FileNotFoundException($layoutPath, 'template not found at the specified path');
     }
 }
Example #14
0
 /**
  * Gets the DBTable object by its name
  *
  * @param string $name name of the table to look up
  * @throws ArgumentException thrown when no DBTable object identified by name found
  * @return DBTable
  */
 function getTable($name)
 {
     Assert::isScalar($name);
     if (!isset($this->tables[$name])) {
         throw new ArgumentException('name', 'not found');
     }
     return $this->tables[$name];
 }
Example #15
0
 /**
  * @param array of string $fields
  */
 function __construct($name, DBTable $table, array $fields)
 {
     Assert::isScalar($name);
     Assert::isNotEmpty($fields, 'constraint cannot be across zero fields');
     $this->name = $name;
     $this->table = $table;
     $this->fields = $fields;
 }
 function __construct($xmlFilename)
 {
     Assert::isScalar($xmlFilename);
     if (!is_file($xmlFilename)) {
         throw new FileNotFoundException($xmlFilename);
     }
     $this->xmlFilename = $xmlFilename;
 }
 protected function checkNumber($number)
 {
     if ($this->scalar) {
         Assert::isScalar($number);
     } else {
         Assert::isInteger($number);
     }
 }
 function __construct($xmlFilename, DoxyGroup $rootDoxyGroup = null)
 {
     Assert::isScalar($xmlFilename);
     if (!is_file($xmlFilename)) {
         throw new FileNotFoundException($xmlFilename);
     }
     $this->xmlFilename = $xmlFilename;
     parent::__construct($rootDoxyGroup);
 }
 function __construct($xmlDocPath, $link, SiteDocIndexItem $parent = null, $menuId = null)
 {
     Assert::isScalar($xmlDocPath);
     if (!file_exists($xmlDocPath)) {
         throw new ArgumentException('xmlDocPath', 'xml doc not found');
     }
     $this->xmlDocPath = $xmlDocPath;
     parent::__construct($link, $parent, $menuId);
 }
 function __construct($xmlFilename, SiteDoc $siteDoc = null)
 {
     Assert::isScalar($xmlFilename);
     if (!is_file($xmlFilename)) {
         throw new FileNotFoundException($xmlFilename);
     }
     $this->xmlFilename = $xmlFilename;
     parent::__construct($siteDoc);
 }
 /**
  * @param string $name name of the varible to import
  * @param WebRequestPart $part part of the request to look up. Default is GET
  * @param boolean $isOptional whether parameter is optional
  * @param mixed $defaultValue parameter's default value to use in case when variable is
  * 			not presented within the IWebContext
  */
 function __construct($name, WebRequestPart $part = null, $isOptional = false, $defaultValue = null)
 {
     Assert::isScalar($name);
     Assert::isBoolean($isOptional);
     $this->name = $name;
     $this->requestPart = $part ? $part : new WebRequestPart(WebRequestPart::GET);
     $this->isOptional = $isOptional;
     $this->defaultValue = $defaultValue;
 }
 function __construct($link, SiteDocIndexItem $parent = null, SitePart $sitePart = null)
 {
     Assert::isScalar($link);
     $this->parent = $parent;
     if ($this->parent) {
         $this->parent->addChild($this);
     }
     $this->link = $link;
     $this->sitePart = !$sitePart && $parent ? $parent->getSitePart() : $sitePart;
 }
Example #23
0
 function __construct($id, DoxyGroup $parent = null, $gid = null)
 {
     Assert::isScalar($id);
     Assert::isScalarOrNull($gid);
     $this->id = $id;
     $this->parent = $parent;
     $this->gid = $gid ? $gid : $this->generateGid();
     if ($this->parent) {
         $this->parent->addInner($this);
     }
 }
 function __construct($xmlFilename, $prefix = '/', SiteDocIndexItem $rootIndex = null)
 {
     Assert::isScalar($xmlFilename);
     Assert::isScalar($prefix);
     if (!is_file($xmlFilename)) {
         throw new FileNotFoundException($xmlFilename);
     }
     $this->xmlFilename = $xmlFilename;
     $this->xmlRoot = dirname($xmlFilename);
     $this->prefix = $prefix == '/' ? '' : rtrim($prefix, '/');
     parent::__construct($rootIndex);
 }
 /**
  * @param string $name name of the property
  * @param array list of database field names
  * @param OrmPropertyType property type
  * @param false property visibility
  * @param boolean whether the property unique or not
  */
 function __construct($name, array $fields, OrmPropertyType $type, OrmPropertyVisibility $visibility, AssociationMultiplicity $multiplicity, $isUnique = false, $isIdentifier = false)
 {
     Assert::isScalar($name);
     Assert::isBoolean($isUnique);
     Assert::isBoolean($isIdentifier);
     $this->name = $name;
     Assert::isTrue(sizeof($fields) == $type->getColumnCount(), 'wrong DB field count');
     $this->fields = $fields;
     $this->type = $type;
     $this->visibility = $visibility;
     $this->multiplicity = $multiplicity;
     $this->isUnique = $isUnique;
     $this->isIdentifier = $isIdentifier;
 }
 /**
  * @return array
  */
 private function getChildNodeSet(SimpleXMLElement $node, $childNodeName)
 {
     Assert::isScalar($childNodeName);
     $nodes = (array) $node;
     if (!isset($nodes[$childNodeName])) {
         $nodes = array();
     } else {
         if ($nodes[$childNodeName] instanceof SimpleXMLElement) {
             $nodes = array($nodes[$childNodeName]);
         } else {
             $nodes = $nodes[$childNodeName];
         }
     }
     return $nodes;
 }
 function acquire($key)
 {
     Assert::isScalar($key);
     $mseconds = 0;
     $result = false;
     while ($mseconds < 1) {
         try {
             $result = mkdir($this->getDirectoryByKey($key), 0700, false);
             $this->locks[$key] = true;
             break;
         } catch (ExecutionContextException $e) {
             // still exist
             $mseconds += 200;
             usleep(200);
         }
     }
     return $result;
 }
Example #28
0
 /**
  * Searchs for the class by it's name using the added resolvers, loads it in scope of itself
  * and adds it to class cache
  * @param string $classname
  * @return boolean shows whether the class was successfully loaded or not
  */
 function loadClass($classname)
 {
     Assert::isScalar($classname);
     if (TypeUtils::isDefined($classname)) {
         return true;
     }
     foreach ($this->resolvers as $resolver) {
         $result = $resolver->getClassPath($classname);
         if ($result) {
             try {
                 require $result;
                 return true;
             } catch (Exception $e) {
                 $message = sprintf('Exception thrown when autoloading %s from %s:%s', $result, $e->getFile(), $e->getLine());
                 trigger_error($message, E_USER_ERROR);
             }
         }
     }
 }
 /**
  * @param $message
  * @return FormControlError
  */
 function setMessage($message)
 {
     Assert::isScalar($message);
     $this->message = $message;
     return $this;
 }
 /**
  * @return FormControlScalar
  */
 function addError($id, $message)
 {
     Assert::isScalar($id);
     Assert::isScalar($message);
     $this->errors[$id] = $message;
     return $this;
 }