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 DateTime;
use Exception;
use Meritoo\Common\Exception\Date\UnknownDatePartTypeException;
use Meritoo\Common\Type\DatePartType;
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.
* @return null|DatePeriod
*
* @throws Exception
*/
public static function getDatesForPeriod($period)
{
@@ -219,6 +222,7 @@ class Date
* Returns current day of week
*
* @return int
* @throws UnknownDatePartTypeException
*/
public static function getCurrentDayOfWeek()
{
@@ -485,6 +489,8 @@ class Date
* placeholder which is replaced with a number that represents each iteration.
* Default: interval for days.
* @return array
*
* @throws Exception
*/
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
* with next, iterated value.
* @return DateTime
*
* @throws Exception
*/
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\ORM\EntityManager;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\Query\Parameter;
use Doctrine\ORM\QueryBuilder;
@@ -155,9 +156,10 @@ class QueryBuilderUtility
*
* @param EntityManager $entityManager The entity manager
* @param array|ArrayCollection $entities The entities to delete
* @param bool $flushDeleted (optional) If is set to true, flushes the deleted objects.
* Otherwise - not.
* @param bool $flushDeleted (optional) If is set to true, flushes the deleted objects (default
* behaviour). Otherwise - not.
* @return bool
* @throws OptimisticLockException
*/
public static function deleteEntities(EntityManager $entityManager, $entities, $flushDeleted = true)
{

View File

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

View File

@@ -10,6 +10,7 @@ namespace Meritoo\Common\Utilities;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use ReflectionException;
/**
* Useful methods for repository
@@ -23,9 +24,13 @@ class Repository
* Replenishes positions of given 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.
* 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)
{
@@ -60,6 +65,8 @@ class Repository
* @param array $items The items
* @param bool $max (optional) If is set to true, maximum value is returned. Otherwise - minimum.
* @return int
*
* @throws ReflectionException
*/
public static function getExtremePosition($items, $max = true)
{