Update PHPDoc and comments

This commit is contained in:
Meritoo
2018-04-03 08:26:51 +02:00
parent f111174ed2
commit 5578b051a7
4 changed files with 53 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ namespace Meritoo\Common\Utilities;
use DateInterval; use DateInterval;
use DateTime; use DateTime;
use Exception;
use Meritoo\Common\Exception\Date\UnknownDatePartTypeException; use Meritoo\Common\Exception\Date\UnknownDatePartTypeException;
use Meritoo\Common\Type\DatePartType; use Meritoo\Common\Type\DatePartType;
use Meritoo\Common\Type\DatePeriod; use Meritoo\Common\Type\DatePeriod;
@@ -68,6 +69,8 @@ class Date
* *
* @param int $period The period, type of period. One of DatePeriod class constants, e.g. DatePeriod::LAST_WEEK. * @param int $period The period, type of period. One of DatePeriod class constants, e.g. DatePeriod::LAST_WEEK.
* @return null|DatePeriod * @return null|DatePeriod
*
* @throws Exception
*/ */
public static function getDatesForPeriod($period) public static function getDatesForPeriod($period)
{ {
@@ -219,6 +222,7 @@ class Date
* Returns current day of week * Returns current day of week
* *
* @return int * @return int
* @throws UnknownDatePartTypeException
*/ */
public static function getCurrentDayOfWeek() public static function getCurrentDayOfWeek()
{ {
@@ -485,6 +489,8 @@ class Date
* placeholder which is replaced with a number that represents each iteration. * placeholder which is replaced with a number that represents each iteration.
* Default: interval for days. * Default: interval for days.
* @return array * @return array
*
* @throws Exception
*/ */
public static function getDatesCollection(DateTime $startDate, $datesCount, $intervalTemplate = 'P%dD') public static function getDatesCollection(DateTime $startDate, $datesCount, $intervalTemplate = 'P%dD')
{ {
@@ -530,6 +536,8 @@ class Date
* @param string $intervalTemplate (optional) Template used to build date interval. The placeholder is replaced * @param string $intervalTemplate (optional) Template used to build date interval. The placeholder is replaced
* with next, iterated value. * with next, iterated value.
* @return DateTime * @return DateTime
*
* @throws Exception
*/ */
public static function getRandomDate(DateTime $startDate = null, $start = 1, $end = 100, $intervalTemplate = 'P%sD') public static function getRandomDate(DateTime $startDate = null, $start = 1, $end = 100, $intervalTemplate = 'P%sD')
{ {

View File

@@ -10,6 +10,7 @@ namespace Meritoo\Common\Utilities;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\Query\Parameter; use Doctrine\ORM\Query\Parameter;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
@@ -155,9 +156,10 @@ class QueryBuilderUtility
* *
* @param EntityManager $entityManager The entity manager * @param EntityManager $entityManager The entity manager
* @param array|ArrayCollection $entities The entities to delete * @param array|ArrayCollection $entities The entities to delete
* @param bool $flushDeleted (optional) If is set to true, flushes the deleted objects. * @param bool $flushDeleted (optional) If is set to true, flushes the deleted objects (default
* Otherwise - not. * behaviour). Otherwise - not.
* @return bool * @return bool
* @throws OptimisticLockException
*/ */
public static function deleteEntities(EntityManager $entityManager, $entities, $flushDeleted = true) public static function deleteEntities(EntityManager $entityManager, $entities, $flushDeleted = true)
{ {

View File

@@ -59,6 +59,10 @@ class Regex
*/ */
public static function isValidEmail($email) public static function isValidEmail($email)
{ {
/*
* Not a string?
* Nothing to do
*/
if (!is_string($email)) { if (!is_string($email)) {
return false; return false;
} }
@@ -141,6 +145,14 @@ class Regex
*/ */
public static function isValidUrl($url, $requireProtocol = false) public static function isValidUrl($url, $requireProtocol = false)
{ {
/*
* Not a string?
* Nothing to do
*/
if (!is_string($url)) {
return false;
}
$pattern = self::getUrlPattern($requireProtocol); $pattern = self::getUrlPattern($requireProtocol);
return (bool)preg_match($pattern, $url); return (bool)preg_match($pattern, $url);
@@ -154,6 +166,10 @@ class Regex
*/ */
public static function isValidPhoneNumber($phoneNumber) public static function isValidPhoneNumber($phoneNumber)
{ {
/*
* Not a string?
* Nothing to do
*/
if (!is_string($phoneNumber)) { if (!is_string($phoneNumber)) {
return false; return false;
} }
@@ -814,6 +830,10 @@ class Regex
*/ */
public static function isValidBundleName($bundleName) public static function isValidBundleName($bundleName)
{ {
/*
* Not a string?
* Nothing to do
*/
if (!is_string($bundleName)) { if (!is_string($bundleName)) {
return false; return false;
} }
@@ -851,6 +871,10 @@ class Regex
*/ */
public static function isValidHtmlAttribute($htmlAttribute) public static function isValidHtmlAttribute($htmlAttribute)
{ {
/*
* Not a string?
* Nothing to do
*/
if (!is_string($htmlAttribute)) { if (!is_string($htmlAttribute)) {
return false; return false;
} }
@@ -868,6 +892,10 @@ class Regex
*/ */
public static function areValidHtmlAttributes($htmlAttributes) public static function areValidHtmlAttributes($htmlAttributes)
{ {
/*
* Not a string?
* Nothing to do
*/
if (!is_string($htmlAttributes)) { if (!is_string($htmlAttributes)) {
return false; return false;
} }
@@ -885,6 +913,10 @@ class Regex
*/ */
public static function isBinaryValue($value) public static function isBinaryValue($value)
{ {
/*
* Not a string?
* Nothing to do
*/
if (!is_string($value)) { if (!is_string($value)) {
return false; return false;
} }

View File

@@ -10,6 +10,7 @@ namespace Meritoo\Common\Utilities;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use ReflectionException;
/** /**
* Useful methods for repository * Useful methods for repository
@@ -23,9 +24,13 @@ class Repository
* Replenishes positions of given items * Replenishes positions of given items
* *
* @param array $items The items * @param array $items The items
* @param bool $asLast (optional) If is set to true, items are placed at the end. Otherwise - at the top. * @param bool $asLast (optional) If is set to true, items are placed at the end (default behaviour). Otherwise
* - at top.
* @param bool $force (optional) If is set to true, positions are set even there is no extreme position. * @param bool $force (optional) If is set to true, positions are set even there is no extreme position.
* Otherwise - if extreme position is not found (is null) replenishment is stopped / skipped. * Otherwise - if extreme position is not found (is null) replenishment is stopped / skipped
* (default behaviour).
*
* @throws ReflectionException
*/ */
public static function replenishPositions($items, $asLast = true, $force = false) public static function replenishPositions($items, $asLast = true, $force = false)
{ {
@@ -60,6 +65,8 @@ class Repository
* @param array $items The items * @param array $items The items
* @param bool $max (optional) If is set to true, maximum value is returned. Otherwise - minimum. * @param bool $max (optional) If is set to true, maximum value is returned. Otherwise - minimum.
* @return int * @return int
*
* @throws ReflectionException
*/ */
public static function getExtremePosition($items, $max = true) public static function getExtremePosition($items, $max = true)
{ {