public function fromProperty(string $propertyName)
    {
        $classType = $this->classType;
        /** @var FinalizedClassDefinition $definition */
        $definition = $classType::definition();
        if (!$definition->hasProperty($propertyName)) {
            throw InvalidArgumentException::format(
                    'Invalid call to %s: property %s::$%s does not exist',
                    __METHOD__, $this->classType, $propertyName
            );
        }

        $this->fromCallback(function (ITypedObject $object) use ($propertyName) {
            return $object->toArray()[$propertyName];
        });
    }
public function fromProperty(string $propertyName)
    {
        $classType = $this->classType;
        /** @var FinalizedClassDefinition $definition */
        $definition = $classType::definition();
        if (!$definition->hasProperty($propertyName)) {
            throw InvalidArgumentException::format(
                    'Invalid call to %s: property %s::$%s does not exist',
                    __METHOD__, $this->classType, $propertyName
            );
        }

        $this->fromCallback(function (ITypedObject $object) use ($propertyName) {
            return $object->toArray()[$propertyName];
        });
    }
public function fromProperty ( string $ propertyName ) { $ classType = $ this -> classType ; /** @var FinalizedClassDefinition $definition */ $ definition = $ classType :: definition ( ) ; if ( ! $ definition -> hasProperty ( $ propertyName ) ) { throw InvalidArgumentException :: format ( 'Invalid call to %s: property %s::$%s does not exist' , __METHOD__ , $ this -> classType , $ propertyName ) ; } $ this -> fromCallback ( function ( ITypedObject $ object ) use ( $ propertyName ) { return $ object -> toArray ( ) [ $ propertyName ] ; } ) ; }
Labels the object with the value of the supplied property.

@param string $propertyName

@return void
@throws InvalidArgumentException
Labels the object with the value of the supplied property .