You are here

public static function PHPUnit_Framework_Assert::readAttribute in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/src/Framework/Assert.php \PHPUnit_Framework_Assert::readAttribute()

Returns the value of an attribute of a class or an object. This also works for attributes that are declared protected or private.

Parameters

mixed $classOrObject:

string $attributeName:

Return value

mixed

Throws

PHPUnit_Framework_Exception

27 calls to PHPUnit_Framework_Assert::readAttribute()
Framework_AssertTest::testReadAttribute in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::readAttribute @covers PHPUnit_Framework_Assert::getStaticAttribute @covers PHPUnit_Framework_Assert::getObjectAttribute
Framework_AssertTest::testReadAttribute2 in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::readAttribute @covers PHPUnit_Framework_Assert::getStaticAttribute @covers PHPUnit_Framework_Assert::getObjectAttribute
Framework_AssertTest::testReadAttribute3 in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::readAttribute @covers PHPUnit_Framework_Assert::getStaticAttribute @covers PHPUnit_Framework_Assert::getObjectAttribute @expectedException PHPUnit_Framework_Exception
Framework_AssertTest::testReadAttribute4 in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::readAttribute @covers PHPUnit_Framework_Assert::getStaticAttribute @covers PHPUnit_Framework_Assert::getObjectAttribute @expectedException PHPUnit_Framework_Exception
Framework_AssertTest::testReadAttribute5 in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::readAttribute @covers PHPUnit_Framework_Assert::getStaticAttribute @covers PHPUnit_Framework_Assert::getObjectAttribute @expectedException PHPUnit_Framework_Exception

... See full list

File

vendor/phpunit/phpunit/src/Framework/Assert.php, line 2836

Class

PHPUnit_Framework_Assert
A set of assert methods.

Code

public static function readAttribute($classOrObject, $attributeName) {
  if (!is_string($attributeName)) {
    throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string');
  }
  if (!preg_match('/[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*/', $attributeName)) {
    throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'valid attribute name');
  }
  if (is_string($classOrObject)) {
    if (!class_exists($classOrObject)) {
      throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'class name');
    }
    return self::getStaticAttribute($classOrObject, $attributeName);
  }
  elseif (is_object($classOrObject)) {
    return self::getObjectAttribute($classOrObject, $attributeName);
  }
  else {
    throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'class name or object');
  }
}