eZ\Publish\Core\Limitation\SiteAccessLimitationType::acceptValue PHP Method

acceptValue() public method

Makes sure LimitationValue object and ->limitationValues is of correct type.
public acceptValue ( eZ\Publish\API\Repository\Values\User\Limitation $limitationValue )
$limitationValue eZ\Publish\API\Repository\Values\User\Limitation
    public function acceptValue(APILimitationValue $limitationValue)
    {
        if (!$limitationValue instanceof APISiteAccessLimitation) {
            throw new InvalidArgumentType('$limitationValue', 'APISiteAccessLimitation', $limitationValue);
        } elseif (!is_array($limitationValue->limitationValues)) {
            throw new InvalidArgumentType('$limitationValue->limitationValues', 'array', $limitationValue->limitationValues);
        }
        foreach ($limitationValue->limitationValues as $key => $value) {
            // Value must be a CRC32, so can be either as string or integer.
            if (!is_string($value) && !is_int($value)) {
                throw new InvalidArgumentType("\$limitationValue->limitationValues[{$key}]", 'string or integer', $value);
            }
        }
    }

Usage Example

 /**
  * @depends testConstruct
  * @dataProvider providerForTestAcceptValueException
  * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
  *
  * @param \eZ\Publish\API\Repository\Values\User\Limitation $limitation
  * @param \eZ\Publish\Core\Limitation\SiteAccessLimitationType $limitationType
  */
 public function testAcceptValueException(Limitation $limitation, SiteAccessLimitationType $limitationType)
 {
     $limitationType->acceptValue($limitation);
 }